繁体   English   中英

在所有设备上都保持4cm大小的ImageView?

[英]An ImageView that keep the size of 4cm on all devices?

我有一个带有图片的Image视图(它们的大小都完全相同),并且该Image View应该在所有设备(HTC,Sony,Samsung等)上保持其大小。 确切的尺寸并不重要,它应该在3.8x3.8厘米至4.5x4.5厘米之间。 这意味着,如果我要缩放并测量不同设备的屏幕尺寸,则该数字应始终相同。

XML:

<RelativeLayout
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
         >

       <ImageView
           android:id="@+id/testanzeige"
           android:layout_centerHorizontal="true"
           android:layout_centerVertical="true"
           android:src="@drawable/info" 
         android:layout_width="231dp"
            android:layout_height="231dp"/>

更多的资源类型

毫米的单位为毫米。 (10mm等于1cm)

mm Millimeters - Based on the physical size of the screen

在您的情况下,您只需使用40mm x 40mm即可

<ImageView
       android:id="@+id/testanzeige"
       android:layout_centerHorizontal="true"
       android:layout_centerVertical="true"
       android:src="@drawable/info" 
       android:layout_width="40mm"
       android:layout_height="40mm"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM