Ajay
Ajay

Reputation: 219

xamarin android How to increase multiline edit text height with screen height?

I want to manage multi line edit text control's height with respect to device screen height. Height should be 40% of screen.

I have used max lines, lines and min lines properties. If I set these properties then height does change but if screen height changes or device shifted to horizontal then edit text goes out of the screen. in short, multi line edit text height must be dynamic with screen size. It should shrink and expand as other control does with screen size.

Screenshot:

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusableInTouchMode="true"
android:background="#e8eeff">
<EditText
    android:id="@+id/etTextMultiLine"
    android:inputType="textMultiLine"
    android:gravity="top|left"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:scrollbars="vertical"
    android:hint="Enter a Text"
    android:background="@layout/EditTextStyle"
    android:textColorHint="#404144"
    android:textColor="#404144"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="5dp"
    android:padding="5dp" />

Upvotes: 0

Views: 1366

Answers (1)

Chad Mx
Chad Mx

Reputation: 1324

Since you wish to achieve sizes with percentages, consider using PercentFrameLayout as your EditText's parent and just match both weight and height. The documentation says PercentFrameLayout is deprecated, so consider the replacement suggested, ConstraintLayout.

Upvotes: 1

Related Questions