anangfaturrohman
anangfaturrohman

Reputation: 441

Automatically adjusts layout when the keyboard is shown

I just want to know, why does adjustResize not work in my application? I have declared android:fitsSystemWindows in the root layout, but it still doesn't work, so what's wrong with my layout?

activity_main:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/mainLayout"
    android:fitsSystemWindows="true" >

    <RelativeLayout
        android:id="@+id/con"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="2" >

        <!-- ScrollView CheckBox layout -->
        <ScrollView
            android:id="@+id/scr"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_alignParentTop="true"
            android:padding="8dp"
            android:layout_weight="2" >

            <!-- LinearLayout CheckBox MainLayout -->
            <LinearLayout
                android:id="@+id/CheckBoxLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" />

        </ScrollView>

        <RelativeLayout
            android:id="@+id/bottomLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_below="@id/scr"
            android:layout_weight="1" >

            <EditText
                android:id="@+id/edt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:focusable="false"
                android:clickable="false" />
            <Button
                android:id="@+id/tambah"
                android:layout_width="wrap_content"
                android:layout_height="50dip"
                android:text="Tambah"
                android:layout_below="@id/edt"
                android:layout_alignParentRight="true"
                android:onClick="fTambah" />
            <Button
                android:id="@+id/space"
                android:layout_width="wrap_content"
                android:layout_height="50dip"
                android:text="Space"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_below="@id/tambah"
                android:onClick="fSpace" />
            <CheckBox
                android:id="@+id/noCheck"
                android:text="No CheckBox ?"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/edt"
                android:layout_alignParentLeft="true" />
            <CheckBox
                android:id="@+id/newSet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@id/noCheck"
                android:text="Edit ?" />
            <EditText
                android:id="@+id/edit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_toLeftOf="@id/space" />
        </RelativeLayout>
    </RelativeLayout>
</LinearLayout>

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.afr.app.jadwal"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="25" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity 
            android:name="com.afr.app.jadwal.MainActivity"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

Upvotes: 0

Views: 70

Answers (1)

ManxDev
ManxDev

Reputation: 108

Change

android:layout_height="match_parent"

in your ScrollView to

android:layout_height="wrap_content"

Works on my test example of your code

Upvotes: 1

Related Questions