Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27133

Set height for EditText no more than the coordinates of the center screen

I am new in Android.

Now I need EditText which should be no more than a certain size. Now I try to use this code:

 <EditText
        android:id="@+id/editText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:inputType="text|textMultiLine"
        android:minLines="3" />

layout_height="wrap_content" - in this case my EditText height is equal to the number of letters in it.

But I need make restriction for height for example set height for EditText no more than of center screen.

I know that we have some problem because Android use many of different screen.

Have we got a way for calculate this height. I mean the bottom border of EditText should not be more than center of screen.

Thanks a lot!

Upvotes: 0

Views: 573

Answers (1)

Tim
Tim

Reputation: 6712

You can restrict an EditText by adding additional values

android:maxLines

Furthermore you could add

android:maxHeight

with some kind of dp value.

I wouldn't use other techniques for restricting the height.

Upvotes: 1

Related Questions