2015-05-13 27 views
0

我添加了一個EditText到記事本應用程序的佈局。當我嘗試輸入EditText時,我意識到,如果文本字符串比屏幕邊緣更長,它將繼續沿直線前進,而不是下一行。下面是佈局的代碼。Android Edittext測試不會停在屏幕邊界

<ScrollView 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
android:fillViewport="true" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/noteEditorLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/noteEditor" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:hint="@string/enterText" 
     android:textSize="18sp" 
     android:background="#00000000" 
     android:inputType="textMultiLine|textCapSentences" 
     android:gravity="top" 
     android:layout_weight="1"> 
    </EditText> 
</LinearLayout> 

感謝。

回答

0

嘗試設置你的

android:layout_width="0dp"

android:layout_width="match_parent"

代替

,或者如果你堅持使用layout_weight屬性,此行添加到您的LinearLayout

android:weightSum="1" 
+0

完美運作。謝謝。 – Justin

+0

不要忘記upvote。 – Razgriz

+1

我會盡我所能但StackOverflow說我需要更高的聲譽來做到這一點。 – Justin