开发者

screen sizes vs buttons position

i am trying to build this application and it's looking great on a regular 3.7in WVGA screen the problem is as you see when you install the app on a larger screen it will look off. any ideas on how to fix this? i would like to have the buttons stay under the text on top of the screen. here is my XML.

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout android:layout_width="fill_parent"
        android:orientation="vertical" android:layout_height="fill_parent" android:paddingLeft="60dip" android:paddingRight="60dip">


        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:textColor="#ffd700"
            android:layout_marginBottom="2dip" android:id="@+id/ArButton01"
            android:background="@drawable/android_button" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton02" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Bu开发者_运维技巧tton android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton03" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton04" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton05" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton06" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton07" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton08" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:background="@drawable/android_button"
            android:textColor="#ffd700" android:layout_marginBottom="2dip"
            android:id="@+id/ArButton09" android:textSize="25dip"
            android:layout_width="fill_parent" />

        <Button android:layout_height="wrap_content"
            android:layout_gravity="center" android:textStyle="bold"
            android:background="@drawable/android_button" android:textColor="#ffd700"
            android:layout_marginBottom="2dip" android:id="@+id/ArButton10"
            android:textSize="25dip" android:layout_width="fill_parent" />

        <!-- <Button android:layout_height="wrap_content" -->
        <!-- android:layout_width="200dip" android:layout_gravity="center" -->
        <!-- android:textStyle="bold" android:background="@drawable/android_button" -->
        <!-- android:textColor="#ffd700" android:layout_marginBottom="2dip" -->
        <!-- android:id="@+id/ArButton11" android:textSize="25dip" /> -->

    </LinearLayout>
</ScrollView>

screen sizes vs buttons position

screen sizes vs buttons position

thank you for looking.


You need to provide different XML Layouts for different devices / screens. For Gingerbread (Android 2.3) there are a total of 8 different supported screen sizes. You can do this, by creating multiple layout folders in your res folder.

Rename your current layout folder to "layout-normal-hdpi" (for WVGA800 on a normal sized screen). Create a new Folder "layout-large-mdpi" (for WVGA800 on a large screen). Both folders are for devices with a WVGA800 resolution, but with different physical sizes of the screen.

Copy your layout XML file from the "layout-normal-hdpi" to the "layout-large-mdpi" and change the button positions, so that it will look the way you want it to look on a devices with a larger screen. Android will automatically choose the correct layout, depending on the hardware of the device.

Please be aware, that the 2 XML files should have exactly the same name, only the name of the folder they are in should be different.

For more Information on other screen sizes and resolutions that are supported, take a look at http://developer.android.com/guide/practices/screens_support.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜