与大小比例添加图片到我的布局屏幕的Android尺寸 [英] add image to my layout with size proportional to dimension of screen android
本文介绍了与大小比例添加图片到我的布局屏幕的Android尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用我有应该有25%的宽度和屏幕高度的图像。
我希望这是显而易见的。这就是我已经尝试过,但不起作用。谢谢你。
< ImageView的
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =0.25
机器人:SRC =@绘制/鱼
机器人:scaleType =fitCenter
/>
解决方案
只是线性布局使用 < LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
机器人:weightSum =100>
< ImageView的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =25
机器人:背景=@绘制/ ic_launcher/>
< / LinearLayout中>
In my application i have an image that should have 25% width and height of screen. I hope this is clear. This is what i'm already tried but doesn't work. Thank you.
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.25"
android:src="@drawable/fish"
android:scaleType="fitCenter"
/>
解决方案
Just use this with Linear Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="25"
android:background="@drawable/ic_launcher"/>
</LinearLayout>
这篇关于与大小比例添加图片到我的布局屏幕的Android尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文