Android: Vertical alignment for multi line EditText (Text area)

后端 未结 7 536
独厮守ぢ
独厮守ぢ 2020-12-04 06:54

I want to have 5 lines for the height of the text area. I am using the following code.



        
相关标签:
7条回答
  • 2020-12-04 07:28

    U can use this Edittext....This will help you.

    <EditText
    android:id="@+id/EditText02"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:lines="5"
    android:gravity="top|left"
    android:inputType="textMultiLine" />
    
    0 讨论(0)
  • 2020-12-04 07:31

    Use android:gravity="top"

    0 讨论(0)
  • 2020-12-04 07:32

    This is similar to CommonsWare answer but with a minor tweak: android:gravity="top|start". Complete code example:

    <EditText
        android:id="@+id/EditText02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:lines="5"
        android:gravity="top|start"
        android:inputType="textMultiLine"
        android:scrollHorizontally="false" 
    />
    
    0 讨论(0)
  • 2020-12-04 07:32
    <EditText android:id="@+id/EditText02" android:layout_width="120dp"
        android:layout_height="wrap_content" android:lines="5" android:layout_centerInParent="true"
        android:gravity="top|left" android:inputType="textMultiLine"
        android:scrollHorizontally="false" android:minWidth="10.0dip"
        android:maxWidth="180dip" />
    

    it will work

    0 讨论(0)
  • 2020-12-04 07:38

    Use this:

    android:gravity="top"
    

    or

    android:gravity="top|left"
    
    0 讨论(0)
  • 2020-12-04 07:46

    I think you can use layout:weight = 5 instead android:lines = 5 because when you port your app to smaller device - it does it nicely.. well, both attributes will accomplish your job..

    0 讨论(0)
提交回复
热议问题