我的 LinearLayout 包含 2 个 TextView(TextView1 和 TextView2)和一个 ImageView。现在我希望 LinearLayout 始终具有固定高度,即 ThextView1 的高度,以便 ImageView 始终使用 fill_parent 将其图像调整为 TextView1 的高度。
_____________________________________
|TextView1------------------ ImageView|
|TextView1 --- TextView2 --- ImageView|
|TextView1 ----------------- ImageView|
有点难以解释...ImageView 始终应具有 TextView1 的高度并调整其图像的大小(同时保持原始纵横比)。
这是否可以仅使用 layout-xml 来完成,还是我需要以编程方式来完成?
我希望你能帮助我:)
最佳答案
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
... />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
... />
</LinearLayout>
我还没有测试过这个。你指的是这个吗?
关于android - 将 ImageView 调整为 TextView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15602947/