When I click on the summgrn , the keyboard appears, but along with its appearance, it closes all the elements, and should lift everything to the top. What would the user not svaypil down in order to write to the summgrn amount.

Before user clicked:

enter image description here

After

enter image description here

The manifest is: android:windowSoftInputMode="stateHidden"

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/fone" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="bottom" > <ImageView android:id="@+id/imageView21" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/bg_shkaf" /> <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="50dp" android:orientation="vertical" > <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="1) Введите сумму вашего счета" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="2) Сгенерируйте код" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="3) Покажите код официанту" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="4) Получите бонус на счет" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> </LinearLayout> <TextView android:id="@+id/textView6" android:layout_width="258dp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="30dp" android:text="бонусы " android:textColor="#fff" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="80dp" android:orientation="horizontal" > <TextView android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="10dp" android:layout_marginRight="5dp" android:text="Введите сумму" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" > </RelativeLayout> <RelativeLayout android:layout_width="wrap_content" android:layout_height="40dp" android:layout_marginRight="10dp" android:background="@drawable/button_radius_get_bonus" android:gravity="center_vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <EditText android:id="@+id/summgrn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:hint="1200" android:inputType="number" android:maxLines="1" android:maxLength="5" android:background="@null" android:textColor="#fff" android:textColorHint="#91623f" > <requestFocus /> </EditText> <TextView android:id="@+id/textView8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:layout_marginRight="20dp" android:layout_weight="1" android:text="грн." android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" android:textSize="20dp" /> </LinearLayout> </RelativeLayout> </LinearLayout> </LinearLayout> <TextView android:id="@+id/textView9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="100dp" android:layout_marginTop="20dp" android:text="и покажите код официанту" android:textColor="#fff" /> </LinearLayout> </ScrollView> <RelativeLayout android:id="@+id/generateBonus" android:layout_width="match_parent" android:layout_height="50dp" android:layout_gravity="bottom" android:background="#9a5f35" android:gravity="center_horizontal" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"> <TextView android:id="@+id/textView10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Получить" android:textColor="#fff" android:textSize="20dp" /> </RelativeLayout> </RelativeLayout> </LinearLayout> 
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

3 answers 3

Alternatively, you can scroll ScrollView to the very end

 scrollview.fullScroll(View.FOCUS_DOWN); 
  • I assigned onClickListener to my EditText and wrote that when I clicked scrollview.fullScroll(View.FOCUS_DOWN); but in the end nothing has changed - nesalexy

Your problem can be solved through the manifest file. In the tag of your activity, add the following attribute:

 android:windowSoftInputMode="adjustPan"> 

adjustPan - moves the content area up,
adjustResize - will reduce the height of the content.

  • in the manifest wrote as you said android:windowSoftInputMode="adjustPan" nothing has changed - nesalexy

It turned out like this:

  MyEditText.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { isKeyboardShown(MyEditText.getRootView()); } }); //code private boolean isKeyboardShown(View rootView) { /* 128dp = 32dp * 4, minimum button height 32dp and generic 4 rows soft keyboard */ final int SOFT_KEYBOARD_HEIGHT_DP_THRESHOLD = 128; Rect r = new Rect(); rootView.getWindowVisibleDisplayFrame(r); DisplayMetrics dm = rootView.getResources().getDisplayMetrics(); /* heightDiff = rootView height - status bar height (r.top) - visible frame height (r.bottom - r.top) */ int heightDiff = rootView.getBottom() - r.bottom; /* Threshold size: dp to pixels, multiply with display density */ boolean isKeyboardShown = heightDiff > SOFT_KEYBOARD_HEIGHT_DP_THRESHOLD * dm.density; Log.e( "isKeyboardShown ? " + isKeyboardShown + ", heightDiff:" + heightDiff + ", density:" + dm.density + "root view height:" + rootView.getHeight() + ", rect:" + r, "sd"); if(isKeyboardShown) { //scrollView1 это мой скрол scrollView1.fullScroll(View.FOCUS_DOWN); } return isKeyboardShown; }