长屏幕上的Android XML不同边距

时间:2013-09-05 10:10:09

标签: android xml screen

有没有办法在长屏幕上为XML视图设置不同的边距?

只要屏幕比例非常多样化,我就需要为长屏幕设置一个上边距,例如Samsung Note II(1280x720)才能正确显示我的XML。 每个观点都赞赏。

4 个答案:

答案 0 :(得分:1)

您应该为不同的布局使用不同的文件夹名称。像:

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/drawable-mdpi/my_icon.png        // bitmap for medium density
res/drawable-hdpi/my_icon.png        // bitmap for high density
res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

Read here for details

答案 1 :(得分:0)

您需要创建4种不同的布局以支持多种屏幕尺寸。 请参阅Android Multiple screen support

使用此功能,您可以在更大的布局中设置边距

答案 2 :(得分:0)

在资源中创建名为layout-xhdpi的单独文件夹,并在那里定义具有边距的相应xml,希望它适合您!

答案 3 :(得分:0)

我认为你必须使用相对布局并将你的图像放在drawable中。所以你的图像管理得很好。我做过这样的事情: -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/logosmall"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="180dp"
        android:layout_height="80dp" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/logo2" />
    </LinearLayout>
</RelativeLayout>
相关问题