user1025050
user1025050

Reputation:

android:alignment of text in edittext

I am making an app in which i have to use edit text and when i use this text on samsung galaxy s and emulator , the text starts from center of edittext rather than starting from top.The screen shot and code is as follows`

 <EditText android:id="@+id/tester" 
     android:layout_height="113dip" 
     android:layout_width="420dip" 
     android:background="@drawable/textarea_reason" 
     android:paddingTop="-90dip"/>

When i enter the text in edit text it starts from some gap rather than starting from top`

Upvotes: 3

Views: 11126

Answers (4)

Dmytro Danylyk
Dmytro Danylyk

Reputation: 19796

You need to change gravity parameter.

Java Code

editText.setGravity(Gravity.TOP| Gravity.LEFT); 

XML

<EditText 
    android:id="@+id/tester" 
    android:layout_height="113dip" 
    android:layout_width="420dip" 
    android:background="@drawable/textarea_reason" 
    android:gravity="top|left"/>

Upvotes: 12

Cata
Cata

Reputation: 11211

Try setting edit text's properties singleLine="false" in the xml or minLines to > 1

Upvotes: 0

Kalpesh
Kalpesh

Reputation: 1807

Update yor Edit Text tag like as...

<EditText 
    android:id="@+id/tester" 
    android:layout_height="113dip" 
    android:layout_width="420dip" 
    android:background="@drawable/textarea_reason" 
    android:gravity="top|left"/>

Upvotes: 5

bindal
bindal

Reputation: 1932

You have set Back ground image thats why this problem occurs put android:paddingLeft="20dp" and test

Upvotes: 0

Related Questions