Questions tagged [android-widget]

Either relates to Home Screen widgets, or to general UI elements used on an Android Application screen.

From Android Documentation

Widgets are an essential aspect of home screen customization. You can imagine them as "at-a-glance" views of an app's most important data and functionality that is accessible right from the user's home screen. Users can move widgets across their home screen panels, and, if supported, resize them to tailor the amount of information within a widget to their preference.

Common elements are :

  • AbsoluteLayout
  • AnalogClock
  • AutoCompleteTextView
  • Button
  • CalendarView
  • CheckBox
  • CheckedTextView
  • Chronometer
  • CompoundButton
  • DatePicker
  • DigitalClock
  • EditText
  • ExpandableListView
  • FrameLayout
  • Gallery
  • GridView
  • HorizontalScrollView
  • ImageButton
  • ImageSwitcher
  • ImageView
  • LinearLayout
  • ListView
  • MediaController
  • NumberPicker
  • ProgressBar
  • QuickContactBadge
  • RadioButton
  • RadioGroup
  • RatingBar
  • RelativeLayout
  • ScrollView
  • SearchView
  • SeekBar
  • SlidingDrawer
  • Spinner
  • StackView
  • TabHost
  • TableLayout
  • TableRow
  • TabWidget
  • TextSwitcher
  • TextView
  • TimePicker
  • Toast
  • ToggleButton
  • VideoView
  • ViewAnimator
  • ViewFlipper
  • ViewSwitcher
  • ZoomButton
  • ZoomControls
5711 questions
81
votes
7 answers

How can I make my layout scroll both horizontally and vertically?

I am using a TableLayout. I need to have both horizontal and vertical scrolling for this layout. By default I am able to get vertical scrolling in the view but horizontal scrolling is not working. I am using Android SDK 1.5 r3. I have already tried…
mudit
  • 25,306
  • 32
  • 90
  • 132
80
votes
12 answers

Android EditText Transparent Background

I want to have a transparent background for Android EditText widget. How is that possible?
Sultan Saadat
  • 2,268
  • 6
  • 28
  • 38
75
votes
7 answers

Android Image View Pinch Zooming

I am using code sample from Making Sense of Multitouch for zooming image view. On ScaleListener I added ScaleGestureDetector.getFocusX() and getFocusY()for content to zoom about the focal point of the gesture. It is working fine. The problem is, on…
MobDev
  • 1,489
  • 1
  • 17
  • 26
70
votes
11 answers

How to start a Service when .apk is Installed for the first time

In my Application I am not having any UI part, so I need to start a Service as soon as the Applicaton gets installed on the Device. I saw many links from which the answer was that its not possible but I guess it is surely possible. Just have a look…
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
68
votes
12 answers

Setting Action Bar title and subtitle

I want to set title and subtitile of my action bar before compile time. I got a way to do it like this: ActionBar ab = getActionBar(); ab.setTitle("My Title"); ab.setSubtitle("sub-title"); But I don't want to do it on run time. Is there any xml…
Adil Malik
  • 6,279
  • 7
  • 48
  • 77
68
votes
4 answers

Creating an android smart app banner

Is there any solution for Android devices similar to the iOS 6 smart app banner? Here is the code for smart app banner
user1781238
67
votes
5 answers

How to add multiple widgets in the same app?

I've just finished my Android widget. Now I need to have different sizes of this widget for the user to choose from. For example, I need a medium, small and large size widget, so when the user installs the app and hold the home screen then choose…
BarcaDroid
  • 673
  • 1
  • 6
  • 5
67
votes
6 answers

How to create custom button in Android using XML Styles

I want to make this kind of button [same background & text] colors by using XML Styles that's just for an example, i want to write some other texts, like: About Me Still i am using button created by designer in Photoshop
Sneha
  • 1,051
  • 4
  • 14
  • 23
65
votes
2 answers

Clickable widgets in android

The developer documentation has seemed to have failed me here. I can create a static widget without thinking, I can even create a widget like the analogue clock widget that will update itself, however, I can not for the life of me figure out how to…
Leif Andersen
  • 21,580
  • 20
  • 67
  • 100
64
votes
5 answers

how to play audio file in android

I have a mp3 file in my android mobile, lets it's a xyz.mp3 somewhere in my sdcard. How to play it through my application?
dIvYaNsH sInGh
  • 1,943
  • 3
  • 21
  • 40
63
votes
7 answers

Incorrect Coordinates From getLocationOnScreen/getLocationInWindow

A call to getLocationOnScreen() or getLocationInWindow() both give me a top/Y coordinate that is about ~30px (status/notifications bar's height) too far down. The left/X coordinate is dead on. As I hinted above, I believe the difference is…
nimph
  • 1,597
  • 1
  • 10
  • 11
63
votes
6 answers

Use external fonts in android

I want to use external fonts in my app. I have tried adding new fonts using AssetManager but it did not work. Below is my code: Typeface face; face = Typeface.createFromAsset(getAssets(), "font.otf"); textview.setTypeface(face); but its not…
mudit
  • 25,306
  • 32
  • 90
  • 132
61
votes
6 answers

Android - Is It possible to disable the click of home button

I have an application, when it launches I have to disable all the buttons on Android device, I succeeded in disabling end call and others. I need to disable home button click. It should not produce any action on click. Any suggestions highly…
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
60
votes
13 answers

What android:inputType should I use for entering an IP Address and hostname?

I am building a small Android app where the user will enter an IP address or a hostname into an EditText widget. 90% of the time they will be entering an IP address, the rest of the time - a hostname. So naturally, I want to make it easy for them…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
59
votes
4 answers

Centering the TextView's text vertically in relation to its drawableLeft image

I have this component: The image in the drawableLeft attribute is bigger than…
user940016
  • 2,878
  • 7
  • 35
  • 56