2011-07-12 23 views
1

我有一個包含textviews和edittexts的屏幕。 我想編輯文本等寬。但他們看起來很窄。我不想給一個傾角值。我能怎麼做? 非常感謝。等寬EditText?

<TableLayout 
       android:id="@+id/TableLayout" 
       android:layout_height="wrap_content" 
       android:layout_width="fill_parent" 
       android:layout_centerHorizontal="true" 
       > 


        <TableRow> 
        <TextView 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:text="Name" 
         > 
        </TextView> 
        <EditText 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:id="@+id/name"> 
        </EditText> 
        </TableRow> 


        <TableRow> 
        <TextView 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:text="Last Name" 
         > 
        </TextView> 
        <EditText 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:id="@+id/lastname"> 
        </EditText> 
        </TableRow> 
        </TableLayout> 
+0

如果可能,那麼你應該把什麼類型的佈局或視圖你想要的,然後提及你面臨的問題? –

回答

2

爲什麼不換一個的LinearLayout下面的代碼,並添加屬性的android:layout_weight = 1到兩個TextView的和EditText上。這將幫助你提供兩個相同的寬度!

<TextView 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:text="Name" 
        > 
       </TextView> 
       <EditText 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/name"> 
       </EditText> 

讓我知道如果您有任何疑問

+0

我把android:layout_weight = 1行放在editText中,它就起作用了。謝謝nithinreddy。 – realuser

+0

酷! :)標記爲正確答案,以便稍後訪問它的用戶知道! – nithinreddy

0

,就把這行對XML Android設備上編輯文本:單線=「真」

2

可以給予同等佈局權重文本和編輯照片喜歡android:layout_weight=".5"

1

所有問題的根源是,你給包裹內容爲所有編輯框。由於您沒有默認文本或提示文本,因此它的大小設置爲最小值。嘗試添加一個提示文本或最小寬度,以獲得所需的大小框