0

I have design the layout like below code, But there are EditText, Listview and 3 Button. So those 3 Button all are added in bottom of the parent layout. but when I click the EditText to write something then the buttons are showing like the attached image. but I need to keep that button in the bottom without appearing above the mobile keyboard.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
    android:id="@+id/mainLay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical">



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout"
        android:orientation="vertical"
        android:padding="@dimen/activity">

        <LinearLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="4dp">

            <EditText
                android:id="@+id/vehicleId"
                android:layout_width="0dp"
                android:layout_height="@dimen/height_row"
                android:layout_gravity="center_vertical"
                android:layout_weight="0.5"
                android:background="@null"
                android:gravity="center_vertical"
                android:hint="@string/enter_vehicle_id"
                android:lines="1"
                android:paddingLeft="6dp"
                android:singleLine="true"
                android:textColor="@color/darkGrey"
                android:textColorHint="@color/darkGrey"
                android:textSize="@dimen/normal"
                app:font="@{@string/font_roboto_regular}" />

            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@color/viewColor" />

            <EditText
                android:id="@+id/mileage"
                android:layout_width="0dp"
                android:layout_height="@dimen/height_row"
                android:layout_marginLeft="5dp"
                android:layout_marginStart="5dp"
                android:layout_weight="1"
                android:background="@null"
                android:hint="@string/enter_mileage"
                android:imeOptions="actionNext"
                android:inputType="text"
                android:lines="1"
                android:paddingLeft="5dp"
                android:singleLine="true"
                android:textColor="@color/darkGrey"
                android:textColorHint="@color/darkGrey"
                android:textSize="@dimen/normal"
                app:font="@{@string/font_roboto_regular}" />

        </LinearLayout>

        <View
            android:id="@+id/topView"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/top"
            android:background="@color/viewColor" />

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/bottomView"
            android:layout_below="@+id/top"
            android:layout_marginTop="10dp"
            android:paddingTop="@dimen/activity" />

        <LinearLayout
            android:id="@id/bottomView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginTop="10dp"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="bottom"
                android:orientation="horizontal">

                <Button
                    android:id="@+id/scan"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_weight="1"
                 android:background="@drawable/sel_rounded_rectangle_color1_2"
                    android:gravity="center"
                    android:minHeight="@dimen/min_touch"
                    android:text="@string/scan"
                    android:textAllCaps="false"
                    android:textColor="@color/white"
                    android:textSize="22sp"
                    app:font="@{@string/font_roboto_regular}" />

                <Button
                    android:id="@+id/manual"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="@dimen/activity"
                    android:layout_marginStart="@dimen/activity"
                    android:layout_weight="1"
                    android:background="@drawable/sel_rounded_rectangle_color1_2"
                    android:gravity="center"
                    android:minHeight="@dimen/min_touch"
                    android:text="@string/manual"
                    android:textAllCaps="false"
                    android:textColor="@color/white"
                    android:textSize="22sp"
                    app:font="@{@string/font_roboto_regular}" />

            </LinearLayout>

            <Button
                android:id="@+id/submit"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginTop="@dimen/activity"
                android:background="@drawable/sel_rounded_rectangle_color1_2"
                android:gravity="center"
                android:minHeight="@dimen/min_touch"
                android:text="@string/submit"
                android:textAllCaps="false"
                android:textColor="@color/white"
                android:textSize="22sp"
                app:font="@{@string/font_roboto_regular}" />
        </LinearLayout>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:indeterminate="true"
            android:visibility="gone" />
    </RelativeLayout>

</RelativeLayout>
</layout>

Thanks in advance.

CarinaMj
  • 187
  • 2
  • 14

4 Answers4

2

Add windowSoftInputMode="adjustPan" to your activity . If it is fragment, add this in your conatainer activity.

 <activity android:name="MyActivity"
 ...
 android:windowSoftInputMode="adjustPan"
 ...
</activity>
Suneesh Ambatt
  • 1,347
  • 1
  • 11
  • 41
1

Simply add this code to your Activity tag in Manifest.xml file

<activity
...
android:windowSoftInputMode="adjustPan"> 
</activity>
Fr099y
  • 734
  • 7
  • 15
1

try this for your fragment :

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Oussema Aroua
  • 5,225
  • 1
  • 24
  • 44
0

In your manifest,

<activity
   ..
   android:windowSoftInputMode="adjustNothing">
</activity>

Please note, this will stop pushing the layout up and overlap the buttons when the soft keyboard is shown.

Aveek
  • 849
  • 1
  • 12
  • 28