2014-09-28 101 views
0

爲什麼即使佈局:高度與它的父級匹配,以下佈局中的灰色框(transaction_amount)也不會展開爲可用的全部空間。相對佈局中的TextView不擴展以填充可用空間

enter image description here

<TextView android:id="@+id/transaction_amount" 
    android:layout_width="120dp" 
    android:layout_height="match_parent" 
    android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" 
    android:textColor="@android:color/primary_text_light" 
    android:background="@drawable/rounded_rectangle" 
    tools:text="100"/> 

<TextView 
    android:id="@+id/transaction_name" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/transaction_amount" 
    android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" 
    android:textColor="@android:color/secondary_text_light" 
    tools:text="Mast Kalandar Dinner"/> 

<TextView 
    android:id="@+id/shared_bw_label" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignStart="@id/transaction_name" 
    android:layout_toRightOf="@+id/transaction_amount" 
    android:layout_below="@id/transaction_name" 
    android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small" 
    android:textColor="@android:color/secondary_text_light_nodisable" 
    android:text="Shared Between"/> 

<TextView 
    android:id="@+id/shared_bw_csv" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/shared_bw_label" 
    android:layout_alignBaseline="@id/shared_bw_label" 
    android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small" 
    android:textColor="@android:color/secondary_text_light_nodisable" 
    tools:text="Ashu, Amol"/> 

+0

嘗試改變高度match_parent – CENT1PEDE 2014-09-28 19:52:53

+0

在你提到你做的「寬度」 match_parent你的問題,但空的空間被引起高度的,那麼你應該通過改變高度解決問題。 – CENT1PEDE 2014-09-28 19:55:32

+0

抱歉,我打算編寫layout_height。在代碼中,layout_height是match_parent – 2014-09-28 20:30:45

回答

0

試試這個layout相反,我確定它會幫助你。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="120dp" 
     android:layout_height="match_parent" 
     android:layout_marginRight="10dp" 
     android:background="#ffa" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="100" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Small Text" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Small Text" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </LinearLayout> 
</LinearLayout> 
相關問題