【发布时间】:2015-06-24 17:16:09
【问题描述】:
我有这个线性布局,
<?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="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:background="@color/white"
android:layout_marginTop="1dp"
android:weightSum="1" >
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="left|center"
android:padding="5dp"
android:text="Policy No."
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:src="@drawable/ic_launcher" />
</LinearLayout>
现在我希望图像不缩放,但 ImageView 以匹配父级的高度,TextView 高度设置为包装内容并且无法更改。另外,我不能将 imageView 的高度设置为 wrap_content,因为它会改变整个线性布局的高度,我负担不起。
![问题图片]http://imgur.com/gaef828
现在我想要的是让图像的大小保持与第二行相同,即使第一行的高度增加了。
在此先感谢,任何帮助将不胜感激。
【问题讨论】:
-
不是给图像一个固定高度的选项吗?这似乎是你想要的。例如
android:layout_height="5dp"或其他一些值