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
718
votes
15 answers

Set ImageView width and height programmatically?

How can I set an ImageView's width and height programmatically?
praveenb
  • 10,549
  • 14
  • 61
  • 83
690
votes
13 answers

What does android:layout_weight mean?

I don't understand how to use this attribute. Can anyone tell me more about it?
Mojiiz
  • 7,898
  • 6
  • 26
  • 25
388
votes
25 answers

Set transparent background of an imageview on Android

I am using a web view in which I am adding an image view. How can I set the background of this image view to transparent? I have tried this: mImageview.setBackgroundResource(R.color.trans); Where trans → #00000000 .
mudit
  • 25,306
  • 32
  • 90
  • 132
306
votes
15 answers

Add padding on view programmatically

I am developing Android v2.2 app. I have a Fragment. In the onCreateView(...) callback of my fragment class, I inflate an layout to the fragment like below: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
261
votes
41 answers

Handling click events on a drawable within an EditText

I have added an image right of the text in an EditText widget, using the following XML:
Manikandan
  • 4,358
  • 5
  • 19
  • 13
213
votes
16 answers

How to retrieve the dimensions of a view?

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods getHeight() and getWidth() always return 0. This happens when I format the grid dynamically…
greenset
197
votes
29 answers

Android How to adjust layout in Full Screen Mode when softkeyboard is visible

I have researched a lot to adjust the layout when softkeyboard is active and I have successfully implemented it but the problem comes when I use android:theme="@android:style/Theme.NoTitleBar.Fullscreen" this in my activity tag in manifest file. For…
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
195
votes
11 answers

Disable soft keyboard on NumberPicker

I'm trying to deactivate the soft keyboard when using a NumberPicker to enter numerical values (for aesthetic reasons). This is my layout-xml-code:
171
votes
5 answers

Determine when a ViewPager changes pages

I have three pages (Fragments) inside a ViewPager, however I only want to display a menu item for two of those pages. The code given in a previous SO answer does not seem to work: @Override public void setUserVisibleHint(boolean isVisibleToUser) { …
arjs
  • 2,835
  • 4
  • 22
  • 18
160
votes
3 answers

How to dynamically update a ListView on Android

On Android, how can I a ListView that filters based on user input, where the items shown are updated dynamically based on the TextView value? I'm looking for something like this: ------------------------- | Text View …
Hamy
  • 20,662
  • 15
  • 74
  • 102
150
votes
31 answers

How to disable copy/paste from/to EditText

In my application, there is a registration screen, where i do not want the user to be able to copy/paste text into the EditText field. I have set an onLongClickListener on each EditText so that the context menu showing copy/paste/inputmethod and…
rDroid
  • 4,875
  • 3
  • 25
  • 30
147
votes
15 answers

How to create a date and time picker in Android?

Is there any android widget that enable to pick the date and the time at the same time ? I already use the basic time picker and date picker. But they are not that sexy and user friendly (I found). Do you know if a widget including both date and…
Luc
  • 16,604
  • 34
  • 121
  • 183
142
votes
13 answers

how to get html content from a webview?

Which is the simplest method to get html code from a webview? I have tried several methods from stackoverflow and google, but can't find an exact method. Please mention an exact way. public class htmldecoder extends Activity implements…
user765970
140
votes
19 answers

How to make a smaller RatingBar?

I've added a RatingBar in a layout: But the default style for…
Clem
  • 1,510
  • 2
  • 11
  • 10
134
votes
18 answers

Changing position of the Dialog on screen android

I made a simple AlertDialog in my Activity: View view = layoutInflater.inflate(R.layout.my_dialog, null); AlertDialog infoDialog = new AlertDialog.Builder(MyActivity.this) .setView(view) …
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
1
2 3
99 100