how to create EditText more than one line in android
i am having a hard time creating a EditText which is multiline and width of nearly "100dp". The functionality is what i want that one can enter his short message of 10-20 lines in i开发者_StackOverflow社区t, just like i am typing my question in this BOX.Here is the code i am using to get the desired functionality.
<EditText android:inputType="textMultiLine"
android:text=""
android:layout_height="100dp"
android:layout_width="fill_parent"
android:id="@+id/desc_text"
android:layout_marginLeft = "5dp"
android:layout_marginRight = "5dp"
android:scrollHorizontally ="true"
android:scrollbars = "vertical"
android:singleLine = "false">
</EditText>
but i am getting a edit text of 100dp height but still taking single line input from middle. Please help me how to do this. Thanks
try below code
<EditText
android:id="@+id/msgtext"
android:layout_width="fill_parent"
android:textSize="18sp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:layout_marginRight="10dip"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:inputType="textMultiLine"
android:layout_height="150dip"
android:gravity="top"
android:padding="5dip">
</EditText>
Add android:gravity="top"
to your EditText object
Add this attribute android:lines="3"
to your xml to have a TextView with 3 lines.
Set this property in your xml file android:maxLines=" 20"
20 lines edittext is this.
in Java:
input = findViewById(R.id.desc_text);
input.setMinLines(3);
or in XML:
android:minLines="5"
精彩评论