Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.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 Xml - Fatal编程技术网

Android 为什么布局重量在不同的设备上工作不同

Android 为什么布局重量在不同的设备上工作不同,android,android-layout,android-xml,Android,Android Layout,Android Xml,我有xml,其中图像占屏幕的60%: <RelativeLayout android:id="@+id/rl_images_layout" android:layout_width="0dp" android:layout_weight="6" android:l

我有xml,其中图像占屏幕的60%:

                   <RelativeLayout
                        android:id="@+id/rl_images_layout"
                        android:layout_width="0dp"
                        android:layout_weight="6"
                        android:layout_height="wrap_content" 
                        android:layout_marginBottom ="5dp">

                        <com.my.proj.view.ContentUpdatableImageView
                            android:id="@+id/iv_template1_image"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:adjustViewBounds="true"
                            android:scaleType="fitStart" />

                        <ImageView
                            android:id="@+id/ivResizeIcon"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignRight="@id/iv_template1_image"
                            android:layout_alignTop="@id/iv_template1_image"
                            android:background="@drawable/btn_pinch" />

                        <ImageView
                            android:id="@+id/ivRotateIcon"
                            android:layout_width="55dp"
                            android:layout_height="55dp"
                            android:layout_alignRight="@id/iv_template1_image"
                            android:layout_alignBottom="@id/iv_template1_image"
                            android:layout_marginRight="5dp"
                            android:layout_marginBottom="5dp"
                            android:background="@drawable/btn_rotate"
                            android:visibility="gone" />
                 </RelativeLayout>
                 <View 
                     android:layout_width="0dp"
                     android:layout_height="fill_parent"
                     android:layout_weight="4" />


在一款手机(LG P500)上工作正常,但在另一款手机(HTC Desire HD)上,图像填充率仅为40%。有什么想法吗?

我想这是因为像素密度

请检查这个

试试这个

    android:weightSum="100"  //for parent layout 

    android:layout_weight="60" // for first child //In your case relative layout

    android:layout_weight="40" //for second child //In your case view
你错过了一件事

如果您使用的是
android:layout_weight
,则两个视图的
fill_parent/match_parent
参数应为
layout_heighth
(如果您希望展开屏幕)

因此,将第一个视图中的
布局高度更改为:

android:layout_height="fill_parent" 
“视图”是什么样子的?就我所知,它是一个抽象类,你不应该就这样使用它。在我的脑海里,这似乎是一件很有可能的事情。将其替换为
框架布局
,然后查看视图的其余部分是否正确测量。所有值都在dip(dp)中设置