Home > Enterprise >  Set scroll the screen moving upside when open keyboard in android
Set scroll the screen moving upside when open keyboard in android

Time:01-01

all I am working on performing scrolling while the keyboard is open! My Screen is not scrolling upside while the keyboard appears. I want my screen need to scroll upside when the keyboard appears. As well as it showing me the bottom of the layout. Please suggest guidelines to fulfill that requirement. Is there any other way to do that thing?..... Thanks in advance.

I have tried many of them - In the manifest file put that snippet :

android:windowSoftInputMode="adjustPan" 
android:windowSoftInputMode="adjustResize|stateHidden"

In XML file added the properties:

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/appBarLayout"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:scrollbars="none">

But, this too didn't work. Please suggest any proper solution to it.

This is my XML file :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".work.CreateClassActivity">
 <com.google.android.material.appbar.AppBarLayout
    android:id="@ id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="@color/ColorsWhite"
    android:theme="@style/AppTheme.AppBarOverlay">
    <androidx.appcompat.widget.Toolbar
        android:id="@ id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:weightSum="1"
        app:popupTheme="@style/AppTheme.PopupOverlay">
        <RelativeLayout
            android:id="@ id/relativeLayoutLogo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1.00"
            android:visibility="visible">
            <TextView
                android:id="@ id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_centerVertical="true"
                android:text="@string/create_class"
                android:textColor="@color/colorTextDarkBlue"
                android:textSize="20sp"
                android:textStyle="bold" />
        </RelativeLayout>
    </androidx.appcompat.widget.Toolbar>
 </com.google.android.material.appbar.AppBarLayout>
 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/appBarLayout"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:scrollbars="none">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:weightSum="5">          
    </LinearLayout>
 </ScrollView>  
</RelativeLayout>

And this is my manifest file snippet:

<activity
  android:name=".work.CreateClassActivity"
  android:launchMode="singleTask"
  android:screenOrientation="landscape"
  android:windowSoftInputMode="adjustResize|stateHidden"
  android:theme="@style/AppTheme.NoActionBar" />

CodePudding user response:

You just need to use adjustPan not adjustResize on the corresponding activity in AndroidManifest.xml. You just need to adjust it like this.

<activity
  android:name=".work.CreateClassActivity"
  android:launchMode="singleTask"
  android:screenOrientation="landscape"
  android:windowSoftInputMode="adjustPan"
  android:theme="@style/AppTheme.NoActionBar" />

CodePudding user response:

Solution - Step - 1 : In manifest file put that line in your particular activity: android:windowSoftInputMode="adjustResize"

Step - 2 : In java file and in onCreate() put that line :
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);     
            
Step - 3 : Before run the project - first clean project and uninstall previous apk.

Step - 4 : Run the project and you will get that desired result.
  • Related