简体   繁体   English

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

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

I have an Image view with pictures in it (they are all the exact same size) and the image view should keep it's size over all devices, htc, sony, samsung, and so on. 我有一个带有图片的Image视图(它们的大小都完全相同),并且该Image View应该在所有设备(HTC,Sony,Samsung等)上保持其大小。 it's not important which exact size, it should be between 3.8x3.8 cm and 4.5x4.5 cm. 确切的尺寸并不重要,它应该在3.8x3.8厘米至4.5x4.5厘米之间。 that means, if I'll take a scale and measure the size on screens of different devices, it should be always the same numbers. 这意味着,如果我要缩放并测量不同设备的屏幕尺寸,则该数字应始终相同。

xml: 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"/>

look at More Resource Types 更多的资源类型

There is a unit called mm for Millimeters. 毫米的单位为毫米。 (10mm are equal to 1cm) (10mm等于1cm)

mm Millimeters - Based on the physical size of the screen

in your case you just use 40mm x 40mm . 在您的情况下,您只需使用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