Muhammad Umar Muhammad Umar - 3 months ago 18
Java Question

Keyboard is not scrolling EditText above

I am using this code. However when ever i click on EditText to open the keyboard, the view is not totally up. Why the view is not going up all the way, EditText is hidden behind Keyboard

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/main_bg"
android:id="@+id/mainLayout"
android:focusableInTouchMode="true"
>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:id="@+id/topBar"
android:background="@drawable/top_bar_bg"
>

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal|bottom"
android:layout_centerInParent="true"
>

<ImageView
android:id="@+id/loadingAnimationImg"
android:layout_height="35dp"
android:layout_width="35dp"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:background="@drawable/img05"/>

<ImageView
android:layout_marginBottom="5dp"
android:layout_height="wrap_content"
android:layout_width="120dp"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/simple_logo"/>

</LinearLayout>
</RelativeLayout>

<GridView
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/gridView"
android:numColumns="5"
android:verticalSpacing="5dp" />

<TextView
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@android:color/white"
android:text="@string/hashtagText"
/>


<com.trib.devicebee.custom.FlowLayout
android:id="@+id/flowLayout"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>

<EditText
android:layout_margin="10dp"
android:id="@+id/hashTagsText"
android:hint=""
android:inputType="textFilter"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
/>

<Button
android:id="@+id/goAheadBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/go_ahead_btn"
android:layout_margin="10dp"
/>

</LinearLayout>

Answer

Try to play with android:windowSoftInputMode attribute in AndroidManifest.xml - "adjustPan" could be the answer.

<activity
    android:name="MyActivity"
    android:windowSoftInputMode="adjustPan"
    android:configChanges="orientation|keyboardHidden|screenSize"
    >
</activity>