All Questions

243
votes
12answers
179995 views

Android: View.setID(int id) programmatically - how to avoid ID conflicts?

I'm adding TextViews programmatically in a for-loop and add them to an ArrayList. How do I use TextView.setId(int id)? What Integer ID do I come up with so it doesn't conflict with other IDs?
235
votes
17answers
154262 views

Replace Fragment inside a ViewPager

I'm trying to use Fragment with a ViewPager using the FragmentPagerAdapter. What I'm looking for to achieve is to replace a fragment, positioned on the first page of the ViewPager, with another one. ...
5
votes
3answers
8887 views

Android ImageView Scaling and translating issue

I’m developing an android application (API 19 4.4) and I encounter some issue with ImageViews. I have a SurfaceView, in which I dynamically add ImageViews which I want to react to touch events. On s...
341
votes
8answers
186358 views

What is the main purpose of setTag() getTag() methods of View?

What is the main purpose of such methods as setTag() and getTag() of View type objects? Am I right in thinking that I can associate any number of objects with a single View?
108
votes
5answers
191840 views

Android - Dynamically Add Views into View

I have a layout for a view - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" androi...
487
votes
13answers
203964 views

Difference between a View's Padding and Margin

What is the difference between a View's Margin and Padding?
494
votes
6answers
384081 views

Get root view from current activity

I know how to get the root view with View.getRootView(). I am also able to get the view from a button's onClick event where the argument is a View. But how can I get the view in an activity?
236
votes
20answers
170519 views

Android: How do I prevent the soft keyboard from pushing my view up?

I have a vertical sliding drawer at the bottom of my app. When the soft keyboard opens, it pushes the tab for the drawer up, so it sits atop the keyboard. I actually want it to remain at the bottom of...
226
votes
10answers
148233 views

Animate change of view background color on Android

How do you animate the change of background color of a view on Android? For example: I have a view with a red background color. The background color of the view changes to blue. How can I do a smo...
54
votes
9answers
90652 views

Rotating a view in Android

I have a button that I want to put on a 45 degree angle. For some reason I can't get this to work. Can someone please provide the code to accomplish this?

Previous Next