我有一个包含3个图像视图的水平线性布局.每个图像视图包含200×200像素的相同图像.这是我的布局xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image200" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image200" /> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image200" /> </LinearLayout> </RelativeLayout>
这是它的样子:
注意左边的第三个图像是如何调整大小我假设的,因为没有足够的空间来容纳3x 200像素宽的图像.
我宁愿发生的不是仅缩小最后一张图像,而是将所有三张图像均匀调整大小以使它们都适合整个屏幕.如何设置我的布局以均匀地适合所有三个图像?
谢谢
更新 – 在更改我的设置后,这是什么样的事情:
请注意,图像视图周围的边框仍然是200像素高.为什么会这样?
解决方法
将图像视图的宽度和高度设置为match_parent,并为所有图像视图设置layout_weight = 1.还设置属性android:scaleType =“fitXY”
原文地址:https://www.jb51.cc/android/314064.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。