prevent Android的UI缩放 [英] Prevent Android UI scaling

查看:101
本文介绍了prevent Android的UI缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有在一个线性布局一系列imageviews的。我给自己定的每个imageviews布局宽度和布局height属性来100dp和50dp分别为(我也试过像素,而不是DP和我试图改变imageviews最大大小),但imageviews继续扩大,而不是停留在此固定大小。

我只是想知道如果任何人知道我在做什么错了?

XML:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:方向=垂直
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:背景=@可绘制/ backgroundtop机器人:重力=底和GT;
    <的FrameLayout安卓layout_height =WRAP_CONTENT机器人:layout_width =match_parent机器人:ID =@ + ID / frameLayout1>
        < ImageView的机器人:layout_height =WRAP_CONTENT机器人:layout_width =WRAP_CONTENT机器人:ID =@ + ID / imageView3机器人:SRC =@可绘制/基地机器人:layout_gravity =中心>< / ImageView的>
        <的LinearLayout机器人:ID =@ + ID / linearLayout1机器人:layout_height =WRAP_CONTENT机器人:方向=垂直安卓重力=中心的Andr​​oid版本:paddingTop =50像素机器人:layout_width =match_parent&GT ;
            < ImageView的机器人:SRC =@可绘制/ buttonnews机器人:ID =@ + ID / imageView1机器人:layout_width =123dp机器人:layout_height =49dp机器人:scaleType =中心>< / ImageView的>
            < ImageView的机器人:ID =@ + ID / imageView2机器人:layout_width =163dp机器人:layout_height =49dp机器人:SRC =@可绘制/ buttonevents>< / ImageView的>
        < / LinearLayout中>
    < /的FrameLayout>
< / LinearLayout中>
 

解决方案

测量搭载Android支持的单位可以是:

PX
像素 - 对应于屏幕上实际像素


英寸 - 基于所述屏幕的物理尺寸

毫米
毫米 - 基于所述屏幕的物理尺寸

PT
点 - 英寸基于屏幕的物理尺寸的1/72

DP
密度无关像素 - 即是基于屏幕的物理密度的抽象单元。这些单位是相对于160 dpi的屏幕上,所以一个DP为160 dpi的屏幕上的一个像素。的DP到像素配给将与屏幕密度改变,但不一定是直接地;代替被选择的比例是这是靠近屏幕

SP
规模无关的像素 - 这就像DP单位,但它也缩小了用户的字体大小preference。这是建议,指定的字体大小,当您使用本机,所以他们将被调整为屏幕的密度和用户的preference。

Basically I have a series of imageviews within a linear layout. I've set each of the imageviews layout width and layout height properties to 100dp and 50dp respectively (I've also tried px instead of dp and I've tried changing the imageviews max size) but the imageviews continue to scale rather than staying at this fixed size.

I was just wondering if anyone knows what I am doing wrong?

XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:background="@drawable/backgroundtop" android:gravity="bottom">
    <FrameLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/frameLayout1">
        <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageView3" android:src="@drawable/base" android:layout_gravity="center"></ImageView>
        <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" android:paddingTop="50px" android:layout_width="match_parent">
            <ImageView android:src="@drawable/buttonnews" android:id="@+id/imageView1" android:layout_width="123dp" android:layout_height="49dp" android:scaleType="center"></ImageView>
            <ImageView android:id="@+id/imageView2" android:layout_width="163dp" android:layout_height="49dp" android:src="@drawable/buttonevents"></ImageView>
        </LinearLayout>
    </FrameLayout> 
</LinearLayout> 

解决方案

Unit of measurement supported by android can be :

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ration of dp-to-pixel will change with the screen density, but not necessarily directly; instead the ratio is selected is something that is close to the screen.

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

这篇关于prevent Android的UI缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆