[英]How to set the width of LinearLayout inside RelativeLayout to be independent of screen resolution?
我是Android编程的新手,目前正在构建我的第一个应用程序。 我有一个LinearLayout(带有几个imageviews),它位于基本的RelativeLayout内部。 LinearLayout的xml宽度和高度设置如下:
android:layout_width="135dp"
android:layout_height="match_parent"
LinearLayout中的imageviews设置如下所示:
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="125dp"
android:layout_weight="3"
.....
当我在小屏幕上启动应用程序时,它看起来很正常,但是当屏幕很大时,所有图片都变得非常狭窄(RelativeLayout内部的LinearLayout的宽度在大屏幕和大屏幕上都保持不变)。 我尝试将其设置为百分比,但不允许这样做。 所以我问你:如何将LinearLayout的宽度设置为父RelativeLayout宽度的25%至30%(以使我的图像在任何设备上看起来都很漂亮)。
我知道有一个layout_weight属性,但是它似乎不适用于其他布局中的布局(或者也许我不知道什么是正确的,什么是不正确的)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.