Set android:layout_gravity from code ??

by pawan nimje » Sun, 16 May 2010 02:22:24 GMT

Sponsored Links
 Hi All once again,

In xml we have android:layout_gravity ...

how can i set this for any view [say image button] ... from code ... plz
help ...any kind if suggestion will do ..


ibMap = new ImageButton(getApplicationContext());

ibMap.setLayoutParams(new LayoutParams(width,height));


now i want to set the android:layout_gravity from code ...


Set android:layout_gravity from code ??

by TreKing » Sun, 16 May 2010 08:07:14 GMT


Step 1: Try searching the documentation for "layout gravity".

TreKing - Chicago transit tracking app for Android-powered devices 


Sponsored Links

Set android:layout_gravity from code ??

by Second Dancer » Mon, 17 May 2010 10:52:36 GMT

 LayoutParams provides that

2010/5/16 TreKing <>


Set android:layout_gravity from code ??

by murmeister » Mon, 28 Jun 2010 23:24:41 GMT

 Here's what you are looking for:


The constants defined in android.view.Gravity mimic the names you're
used to seeing in the XML tags.

Good luck.


Other Threads

1. do you think Android going to work this market?

I think that is too early to development applications in Andoid.
What do you think of?


2. T-mobile G1 on O2 (UK) - What to do about updates?

The update system doesn't use SMS.


On Wed, Nov 12, 2008 at 7:01 AM, Sheridan Hutchinson


3. Does Android use ARM Jazelle tech?

4. Intent to open an email attachment

5. UI Update question

6. Question on Service Choice

7. Sms with Intent