
我试图让我的Android应用程序的xml工作,但我有一些问题.我试图在线性布局中并排显示相同大小的图像.它们之间必须有一个边距,左右两侧,顶部.
如何制作这样的xml文件,使其适用于任何屏幕尺寸?
更新:这是我的xml文件的摘录:
<linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_gravity="fill_horizontal" androID:gravity="center" androID:orIEntation="horizontal" ><ImageVIEw androID:ID="@+ID/area" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:contentDescription="@string/app_name" androID:src="@drawable/area_selector" androID:layout_gravity="left" androID:paddingtop="15dp"/> <ImageVIEw androID:ID="@+ID/volume" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:contentDescription="@string/app_name" androID:src="@drawable/volume_selector" androID:layout_gravity="left" androID:paddingtop="15dp" /> </linearLayout>解决方法:
您需要为两个图像提供相同的权重,如下所示
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="horizontal" > <ImageVIEw androID:ID="@+ID/imageVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginBottom="20dp" androID:layout_marginleft="20dp" androID:layout_marginRight="10dp" androID:layout_margintop="20dp" androID:layout_weight="1" androID:src="@drawable/input_cell" /> <ImageVIEw androID:ID="@+ID/imageVIEw2" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginBottom="20dp" androID:layout_marginleft="10dp" androID:layout_marginRight="20dp" androID:layout_margintop="20dp" androID:layout_weight="1" androID:src="@drawable/input_cell" /></linearLayout>在你的情况下使用它
<linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_gravity="fill_horizontal" androID:gravity="center" androID:orIEntation="horizontal" > <ImageVIEw androID:ID="@+ID/area" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:contentDescription="@string/app_name" androID:src="@drawable/area_selector" androID:layout_weight="1" androID:layout_gravity="left" androID:paddingtop="15dp"/> <ImageVIEw androID:ID="@+ID/volume" androID:layout_wIDth="match_parent" androID:layout_weight="1" androID:layout_height="wrap_content" androID:contentDescription="@string/app_name" androID:src="@drawable/volume_selector" androID:layout_gravity="left" androID:paddingtop="15dp" /> </linearLayout> 总结 以上是内存溢出为你收集整理的如何在Android中并排显示两个图像?全部内容,希望文章能够帮你解决如何在Android中并排显示两个图像?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)