Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android XML在长屏幕上显示不同的边距_Android_Xml_Screen - Fatal编程技术网

Android XML在长屏幕上显示不同的边距

Android XML在长屏幕上显示不同的边距,android,xml,screen,Android,Xml,Screen,有没有办法在长屏幕上为XML视图设置不同的边距 一旦屏幕比例相当多样化,我就需要为长屏幕(如Samsung Note II(1280x720))的视图设置一个上边距,以正确显示我的XML。 每一种意见都受到赞赏。您需要创建4种不同的布局以支持多种屏幕尺寸。。 提及 使用此选项,您可以在较大的版面中设置边距您应该为不同的版面使用不同的文件夹名称。比如: res/layout/my_layout.xml // layout for normal screen size ("d

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

一旦屏幕比例相当多样化,我就需要为长屏幕(如Samsung Note II(1280x720))的视图设置一个上边距,以正确显示我的XML。
每一种意见都受到赞赏。

您需要创建4种不同的布局以支持多种屏幕尺寸。。 提及


使用此选项,您可以在较大的版面中设置边距

您应该为不同的版面使用不同的文件夹名称。比如:

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

在资源中创建名为
布局xhdpi
的单独文件夹,并在其中定义适当的xml和页边空白,希望它对您有用

我认为您必须使用相对布局,并将您的图像置于可绘制状态。这样您的图像就可以很好地自行管理。我做过这样的事情:-

<?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>


我认为您应该为不同的屏幕使用
值/dimens.xml
文件。有没有办法一次包含所有长屏幕?基于纵横比还是什么?使用“更多值”文件夹,你可以为不同的屏幕大小应用不同的尺寸(例如文本大小、填充、边距等)。哦,有一个“纵横比”特性,这是我一直在寻找的,但我仍然不确定如何链接不同的版面。是的,我找到了。非常感谢你!