[英]How to set an ImageView and two TextviewS to have the same height?
我有一個ImageView和2 TextView的以下布局,我希望它們都具有相同的高度。 但是,ImageView始終占據屏幕的一半以上。 非常感謝您的幫助。
這是布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:src="@drawable/sprint" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#555555"
android:text="@string/hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="@string/hello" />
</LinearLayout>
嘗試
android:layout_weight="1"
對於所有三個,請確保圖像尺寸不大於為其分配空間定義的尺寸。
嘗試這幾處小改動...
<ImageView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/sprinklicious" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#555555"
android:text="@string/hello" />
<TextView
android:layout_width="wrap_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/hello" />
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.