Skip to content Skip to sidebar Skip to footer

Android Scrollview Autosize

I'm new to android development. I'm attempting to do something that I thought was simple but after much reading, trial and error and determination I've failed to find a solution I

Solution 1:

Try to wrap EditText inside ScrollView to make it scrollable. Setting ScrollViewlayout_weight attribute to 1 and fillViewport to true will force ScrollView to fill available space but never push TextView out of the screen.

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="TextView" /><ScrollViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:fillViewport="true" ><EditTextandroid:id="@+id/editText1"android:layout_width="match_parent"android:layout_height="wrap_content"android:ems="10"android:gravity="top|left"android:inputType="textMultiLine"android:scrollbarAlwaysDrawVerticalTrack="false"android:scrollbarStyle="insideOverlay" ><requestFocus /></EditText></ScrollView></LinearLayout>

Solution 2:

Use minLines and maxLines (of EditText) to specify the minimum and maximum the EditText can shrink/grow to, respectively.

Post a Comment for "Android Scrollview Autosize"