Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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 手机和平板电脑之间的兼容模式_Android_Android Layout_Android Emulator - Fatal编程技术网

Android 手机和平板电脑之间的兼容模式

Android 手机和平板电脑之间的兼容模式,android,android-layout,android-emulator,Android,Android Layout,Android Emulator,读了屏幕兼容模式后,我很困惑。首先,我创建了两个不同大小的相同图像。其次,我只创建了一个布局。第三,我设定了我的形象。最后,我在Galaxy SIIHigh Density中得到了正确的结果,但在模拟平板电脑10中等密度时没有得到正确的结果。请参见两个设备中到右边框的距离 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/a

读了屏幕兼容模式后,我很困惑。首先,我创建了两个不同大小的相同图像。其次,我只创建了一个布局。第三,我设定了我的形象。最后,我在Galaxy SIIHigh Density中得到了正确的结果,但在模拟平板电脑10中等密度时没有得到正确的结果。请参见两个设备中到右边框的距离

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

<Button
    android:id="@+id/button1"
    android:layout_width="150dip"
    android:layout_height="150dip"
    android:text="DENSIDADE" />

<ImageView 
    android:id="@+id/image1"
    android:src="@drawable/mode_tapcolor"
    android:layout_width="150dip"
    android:layout_height="150dip" />

</LinearLayout>


我该怎么办?

您应该创建另一个文件夹值xlarge in res来存储维度值。因此,XML代码应该是:

layout.xml:

values/dimens.xml:

值xlarge/dimens.xml:

因此,当安装apk时,它将为正确的设备使用正确的尺寸值。drawable也是如此,如果需要,您可以创建drawable xlarge来存储平板电脑的图像

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

<Button
    android:id="@+id/button1"
    android:layout_width="@dimen/default_width"
    android:layout_height="@dimen/default_height"
    android:text="DENSIDADE" />

<ImageView 
    android:id="@+id/image1"
    android:src="@drawable/mode_tapcolor"
    android:layout_width="@dimen/default_width"
    android:layout_height="@dimen/default_height" />

</LinearLayout>
<resources>
    <dimen name="default_width">75dip</dimen>
    <dimen name="default_height">75dip</dimen>
</resources>
<resources>
    <dimen name="default_width">150dip</dimen>
    <dimen name="default_height">150dip</dimen>
</resources>