0

I've tried everything, so I decided to post my question here maybe you can help me.

I am creating a basic application just to learn the simplest features. I created a background and 3 buttons for my application, I put these 3 buttons in a LinearLayout for each, in order to center them horizontally on the screen, and I thought that I could create a LinearLayout out these 3 to center them vertically but does not work for me.

Then I created another LinearLayout that pushes them down, but it prevents the usability with different devices, because each screen size I would have to modify this push.

Here's a picture:

button arrangment

<?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_horizontal"
    android:background="@drawable/raintumblrr">

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:paddingTop="32dip" 
    android:paddingBottom="15dip">     
 </LinearLayout>

 <LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:gravity="center">

 <LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:paddingTop="5dip" 
    android:paddingBottom="5dip"
    android:gravity="center_horizontal">

and then the buttons.

can someone help me?

4

1 回答 1

3

Create a RelativeLayout, put your LinearLayout in it, with centerInParent="true" attribute, and wrap_content dimensions.

于 2013-10-01T15:24:11.440 回答