2011-07-20 54 views
1

默認情況下,我的EditText旁邊的看法:我需要對我的EditText做什麼不會改變大小?

<EditText android:layout_height="wrap_content" android:paddingLeft="10dip" 
      android:layout_width="wrap_content" android:gravity="center_vertical" 
      android:inputType="textShortMessage" 
      android:id="@+id/search_string" android:background="@drawable/search_text_bg"> 
      <requestFocus></requestFocus> 
     </EditText> 

當我輸入的文本給它,它改變自身大小和背景的延伸。如何避免它?

回答

3

有一些屬性,你需要設置:

如果你想擁有單行編輯文本,然後做:

android:singleLine="true" 

如果要定義編輯文本的最大行然後執行:

android:maxLines="3" 
+2

非常感謝。所有的答案都非常有幫助 – LackOfKnowledge

2

一種簡單的解決方案是讓android:layout_width="match_parent"android:singleLine="true"

1
android:layout_width="match_parent" 

    OR 

    android:layout_width="fill_parent" // deprecated 

    OR 

    android:layout_width="50dip" // Manually assign any width you want. 
相關問題