dark_illusion_909099
dark_illusion_909099

Reputation: 1099

Is there anyway I could specify the height of the edit text in Android

I want to know if there is any way I could customize the height of an edit text that I am using. I want it to be something similar to this picture Comment Box

This is my code so far;

<EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textMultiLine"
            android:ems="10"
            android:id="@+id/editText"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:background="#ffe7e7e7"
            android:layout_marginTop="10dp" />

I would like to also know if I could notify the user how much character they have got left to write inside that edit text. So like 100 characters left out of 1000 characters. How can I go about doing this ?

Upvotes: 0

Views: 31

Answers (1)

ksarmalkar
ksarmalkar

Reputation: 1894

you can define lines attribute

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lines="5"/>

To keep count, you can add TextWatcher to you EditText

Refer: How to use the TextWatcher class in Android?

http://developer.android.com/reference/android/text/TextWatcher.html

Upvotes: 2

Related Questions