Moving background image when soft keyboard is displayed - android

I have an input popup that I show in the main view of my activity, which has some edit fields. When a popup is displayed, the activity type remains dim in the background (for example, with a warning).

The problem I am facing is that when the keyboard appears, the popup is ok, but the kind of activity in the background is changing. This opinion should be suspended, and I would not have thought that the keyboard would be affected at all. Is there any way to stop this?

I tried adding android: windowSoftInputMode = "adjustPan" to the activity and popup without any luck.

Here is my activity layout:

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical" android:background="@drawable/main_bg">

<include android:id="@+id/header" layout="@layout/common_header" android:layout_width="fill_parent" android:layout_height="wrap_content"/>

 <RelativeLayout
  android:id="@+id/contentLayout"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_margin="5dp"
 >

<include android:id="@+id/btnBar" layout="@layout/common_button_bar" 
android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:layout_alignParentBottom="true"/>  

  <LinearLayout
   android:id="@+id/webLayout"
   android:layout_above="@+id/btnBar"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:background="@drawable/blk"
  android:layout_margin="10dp">

   <WebView
android:id="@+id/WebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:background="@drawable/white"
   >


   </WebView>

  </LinearLayout>
 </RelativeLayout>
    </LinearLayout>

and here is my popup layout:

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="wrap_content"
 android:orientation="vertical"
 android:background="@color/light_grey" android:layout_width="wrap_content"      android:minWidth="300dp">
 <LinearLayout
  android:id="@+id/main_inner_layout"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:background="@color/white"
  android:layout_margin="3dp"
 >

  <TextView
   android:id="@+id/enter_txt"
   android:text="Enter Cup Code Below:"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:gravity="center_horizontal"
   android:textColor="@color/black"
   android:layout_gravity="left"
   android:typeface="sans"
   android:textSize="16dp"
   android:layout_margin="10dp"
      >
  </TextView>
  <RelativeLayout
    android:id="@+id/code_layout"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp"
   android:background="@color/white"
  >
   <EditText
    android:text="12345"
    android:id="@+id/CodeInputOne"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:layout_alignParentLeft="true"
   ></EditText>
   <EditText
    android:text="12345"
    android:id="@+id/CodeInputTwo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_centerHorizontal="true"
   ></EditText>
   <EditText
    android:text="12345"
    android:id="@+id/CodeInputThree"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_alignParentRight="true"
       ></EditText>
  </RelativeLayout>
  <RelativeLayout
   android:id="@+id/btn_layout_top"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginLeft="10dp"
   android:layout_marginTop="10dp"
   android:layout_marginRight="10dp"
   android:background="@color/white"
  >
   <Button
    android:id="@+id/AccountBtn"
    android:textStyle="bold"
    android:text="My Account"
    android:layout_marginRight="5dp"
    android:layout_alignParentLeft="true"
    android:onClick="ClickHandler"
    android:layout_height="40dp"
    android:layout_width="130dp"
   ></Button>
   <Button
    android:id="@+id/SubmitBtn"
    android:textStyle="bold"
    android:text="Submit"
    android:layout_marginLeft="5dp"
    android:layout_alignParentRight="true"
    android:onClick="ClickHandler"
    android:layout_height="40dp"
    android:layout_width="130dp"
   ></Button>

  </RelativeLayout>
  <RelativeLayout
   android:id="@+id/btn_layout_bottom"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp"
   android:background="@color/white"
  >
   <Button
    android:id="@+id/RewardsBtn"
    android:textStyle="bold"
    android:text="Rewards"
    android:layout_marginRight="5dp"
    android:layout_alignParentLeft="true"
    android:onClick="ClickHandler"
    android:layout_height="40dp"
    android:layout_width="130dp"
       ></Button>
   <Button
    android:id="@+id/CancelBtn"
    android:textStyle="bold"
    android:text="Cancel"
    android:layout_marginLeft="5dp"
    android:layout_alignParentRight="true"
    android:onClick="ClickHandler"
    android:layout_height="40dp"
    android:layout_width="130dp"
   ></Button>
   </RelativeLayout>
 </LinearLayout>
</LinearLayout>

Thank!

+3
1

android:windowSoftInputMode="adjustPan|adjustResize"

.

+2

Source: https://habr.com/ru/post/1766301/


All Articles