Skip to content Skip to sidebar Skip to footer

Edittext Moves Textview Out Of The Screen When They Keyboard Is Opening

I have an EditText on the bottom of my layout und a few TextViews on the top. When I click on the EditText it moves from the bottom above the keyboard which is good. But the TextVi

Solution 1:

You may explore windowSoftInputMode that you can configure for your Activity in the AndroidManifest.xml file: activity | Android Developers.

Perhaps windowSoftInputMode="adjustResize" might be useful for you.

In addition to that you will need to change your layout XML to something like:

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_height="match_parent"android:layout_width="match_parent"tools:context="com.ncss.tyfby.Feeling"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"android:orientation="vertical"android:background="#1baa84"><ScrollViewandroid:layout_height="match_parent"android:layout_width="wrap_content"android:layout_weight="1"><LinearLayoutandroid:layout_height="match_parent"android:layout_width="wrap_content"android:orientation="vertical"><TextViewandroid:text="I am"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/iam1"android:textSize="18sp" /><TextViewandroid:text="I am"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/iam2"android:textSize="18sp"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="10dp" /><TextViewandroid:text="I am"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/iam4"android:textSize="18sp"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="10dp" /><TextViewandroid:text="I am"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/iam5"android:textSize="18sp"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="10dp" /><TextViewandroid:text="I am"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/iam3"android:textSize="18sp"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="10dp" /></LinearLayout></ScrollView><LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"><TextViewandroid:text="I am"android:layout_width="wrap_content"android:layout_height="match_parent"android:id="@+id/IamTV"android:layout_weight="0.10"android:textSize="40sp"android:textStyle="normal|bold"android:gravity="bottom" /><EditTextandroid:layout_width="wrap_content"android:inputType="textPersonName"android:ems="10"android:id="@+id/iamAdjective"android:background="@android:drawable/editbox_background_normal"android:hint="powerful"android:layout_height="match_parent"android:layout_weight="1"android:layout_marginLeft="10dp" /><ImageButtonandroid:layout_width="wrap_content"android:layout_height="match_parent"android:id="@+id/send"android:layout_weight="0.10"android:src="@android:drawable/ic_menu_send"android:background="@drawable/transparent"android:onClick="send"android:layout_marginLeft="5dp" /></LinearLayout></LinearLayout>

Solution 2:

You should put your entire layout inside a ScrollView and force that to be above of my_edit_text:

<ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_above="@+id/my_edit_text">

Post a Comment for "Edittext Moves Textview Out Of The Screen When They Keyboard Is Opening"