7 messages in com.googlegroups.android-developers[android-developers] Re: Problem Cent...| From | Sent On | Attachments |
|---|---|---|
| Kyle R | 29 Apr 2008 17:32 | |
| Mark Murphy | 29 Apr 2008 18:04 | |
| Kyle R | 29 Apr 2008 18:51 | |
| Kyle R | 29 Apr 2008 19:13 | |
| Romain Guy | 29 Apr 2008 19:20 | |
| Romain Guy | 29 Apr 2008 19:21 | |
| Kyle R | 29 Apr 2008 19:36 |
| Subject: | [android-developers] Re: Problem Centering and Padding Buttons in Layout![]() |
|---|---|
| From: | Kyle R (kyle...@gmail.com) |
| Date: | 04/29/2008 06:51:20 PM |
| List: | com.googlegroups.android-developers |
That worked perfectly, thank you very much.
On Apr 29, 9:05 pm, Mark Murphy <mmur...@commonsware.com> wrote:
Kyle R wrote:
I cannot figure out how to make 4 buttons, arranged vertically in a row, centered both vertically and horizontally on the screen. I don't get why this is so difficult. Is there a complete list of button attributes for the xml file and what they accomplish somewhere?
What I am trying to achieve would look like:
<- - - - ->
1 2 3 4
<- - - - ->
Try this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" > <Button android:id="@+id/btn1" android:layout_width="300px" android:layout_height="50px" android:textAlign="center" android:padding="15px" android:text="1"/> <Button android:id="@+id/btn2" android:layout_width="300px" android:layout_height="50px" android:textAlign="center" android:padding="15px" android:text="2"/> <Button android:id="@+id/btn3" android:layout_width="300px" android:layout_height="50px" android:textAlign="center" android:padding="15px" android:text="3"/> <Button android:id="@+id/btn4" android:layout_width="300px" android:layout_height="50px" android:textAlign="center" android:padding="15px" android:text="4"/> </LinearLayout> </LinearLayout>
I'll admit I'm not 100% certain why both gravity:"center" attributes are needed -- I'd've expected the one on the outer-most LinearLayout would have done the trick. But, this seems to give the visual effect you're looking for, if I understood you correctly.
--
Mark Murphyhttp://commonsware.com
The Busy Coder's Guide to Android Development -- coming in June 2008!- Hide
quoted text -
- Show quoted text -
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to andr...@googlegroups.com To unsubscribe from this group, send email to andr...@googlegroups.com Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---




