問題描述
我知道這似乎是一個已經回答了數千次的問題,但我還沒有找到任何適合我的東西.
I know it seems it's an already thousand times answered issue but I haven't found anything that works for me.
我在 Android 上有一個 MultiLine EditText,它通過播放"權重 (1) 和高度 (0dip) 來適應視圖大小.我正在使用重力頂部",但它從中間開始.
I have a MultiLine EditText on Android that adapts to the view size by "playing" with the weight (1) and the height (0dip). I am using gravity "top" but it starts in the middle.
我猜這個問題與重量有關.這是代碼(父級是LinearLayout):
I guess the problem it's related with the weight. Here's the code (the parent is a LinearLayout):
<EditText
android:id="@+id/txtContacto"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_gravity="top"
android:inputType="textMultiLine"
android:weight="1">
</EditText>
推薦答案
<EditText
android:id="@+id/txtContacto"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:gravity="top"
android:inputType="textMultiLine"
android:weight="1">
</EditText>
試試上面的代碼.其中布局重力設置edittext,重力設置edittext的內容.
try the above code.. where layout gravity sets the edittext and gravity sets the content of edittext.
這篇關于Android中的MultiLine EditText,光標從頂部開始的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!