Android: windowSoftInputMode = "adjustResize" does not affect the UI

I know there are similar questions in this regard. But I am completely helpless.
I have a multi-line editor that fits in LinearLayout

after multiple items. And when entering text, it is hidden.
The solution to this was to add the property android:windowSoftInputMode="adjustResize"

to the manifest file. It had no effect.
Further searching on SO, I found that I need to add a property android:fitsSystemWindows="true"

to the element of the root layout. However, it doesn't work. What is the problem?

Here is the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mytasks">
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".TaskDetails"
            android:label="@string/title_activity_task_details"
            android:windowSoftInputMode="adjustResize"
            >
        </activity>
    </application>
</manifest>

      

Operation layout file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    android:layout_alignParentBottom="true"
    android:fitsSystemWindows="true"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.mytasks.TaskDetails">

    <TextView
        android:text="Short description of the task"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:textSize="@dimen/abc_text_size_medium_material"
        android:typeface="sans"
        android:layout_margin="7dp"
     />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/sd"
        android:hint="e.g. To meet doctor"
        android:layout_margin="7dp"
    />

    <TextView
        android:text="Type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="7dp"
        android:textStyle="bold"
        android:textSize="@dimen/abc_text_size_medium_material"
        android:typeface="sans"

        />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/type"
        android:entries="@array/type"
        android:layout_margin="7dp"
    />

    <TextView
        android:text="Priority"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="7dp"
        android:textStyle="bold"
        android:textSize="@dimen/abc_text_size_medium_material"
        android:typeface="sans"
        />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/priority"
        android:entries="@array/priority"
        android:layout_margin="7dp"
    />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Description"
        android:layout_margin="7dp"
        android:textStyle="bold"
        android:textSize="@dimen/abc_text_size_medium_material"
        android:typeface="sans"
        />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="7dp"
        >

    <EditText
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:singleLine="false"
        android:id="@+id/description"
        android:inputType="textMultiLine"
        android:gravity="top"
        android:lines="4"
        android:maxLines="10"
        android:scrollbars="vertical"
    />
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="7dp"
        >
        <Button
            android:id="@+id/save"
            android:text="Save"
            android:layout_weight="1"
            android:layout_width="0dip"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/cancel"
            android:text="Cancel"
            android:layout_weight="1"
            android:layout_width="0dip"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>

      

Screenshots:

Initially:

enter image description here

After displaying the keyboard:

enter image description here

+3


source to share


1 answer


Use the adjustPan parameter to translate the screen.



Or put all the margins of your screen in a ScrollView so the area can be shrunk down.

+1


source







All Articles