2016-10-01 72 views
0


我有2個問題與下面的代碼和谷歌不能幫助我:/
1. android.support.design.widget.TextInputLayout 只是出現在海誓山盟,它們不共享像他們應該這樣的線。如果我刪除設計,並只留下Edittexts,它工作正常。

2.寬度大小android.support.design.widget.TextInputLayout設置爲'match_parent',但它只顯示一條小行。只有當我設置數字dp值時纔會更改。

android.support.design.widget.TextInputLayout - 雙重麻煩

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_below="@id/rgGender"> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/etDay" 
     android:hint="Day" 
     android:inputType="number" 
     /> 
    </android.support.design.widget.TextInputLayout> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/etMonth" 
     android:hint="Month" 
     /> 
    </android.support.design.widget.TextInputLayout> 
    </LinearLayout> 

回答

0

這是因爲你是給layout_width="match_parent"到這兩者都應該是平鋪(android:orientation="horizontal")調整和空間分配時間的LinearLayout的第一個孩子得到父母的整個寬度同級TextInputLayouts所以沒有剩下的第二個。

MATCH_PARENT意味着該視圖的大小必須與它的父級一樣大,否則會減去父級的填充。

WRAP_CONTENT意味着視圖要足夠大以適應其自己的內部內容,並考慮其自己的填充。

所以,要麼給wrap_content寬度給兄弟姐妹,要麼如果你想在任何比例的兄弟姐妹中分割完整的寬度,那麼使用weight屬性。

+0

@Shay嘿...我希望我的回答是解決你的問題,如果是的話,做好標記。 – Dipika