Automatically adjusts layout when the keyboard is shown












0















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>









share|improve this question























  • Possible duplicate of android:fitsSystemWindows not working

    – Ankur Aggarwal
    Nov 22 '18 at 11:24











  • try same with android:windowSoftInputMode="adjustPan"

    – Chetan Shelake
    Nov 22 '18 at 11:24











  • -->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

    – Harshil kakadiya
    Nov 22 '18 at 11:26











  • add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

    – Ali
    Nov 22 '18 at 11:27











  • That also doesn't work, the keyboard covers the bottom layout and edittext

    – anangfaturrohman
    Nov 22 '18 at 11:30
















0















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>









share|improve this question























  • Possible duplicate of android:fitsSystemWindows not working

    – Ankur Aggarwal
    Nov 22 '18 at 11:24











  • try same with android:windowSoftInputMode="adjustPan"

    – Chetan Shelake
    Nov 22 '18 at 11:24











  • -->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

    – Harshil kakadiya
    Nov 22 '18 at 11:26











  • add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

    – Ali
    Nov 22 '18 at 11:27











  • That also doesn't work, the keyboard covers the bottom layout and edittext

    – anangfaturrohman
    Nov 22 '18 at 11:30














0












0








0








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>









share|improve this question














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>






android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 11:14









anangfaturrohmananangfaturrohman

52




52













  • Possible duplicate of android:fitsSystemWindows not working

    – Ankur Aggarwal
    Nov 22 '18 at 11:24











  • try same with android:windowSoftInputMode="adjustPan"

    – Chetan Shelake
    Nov 22 '18 at 11:24











  • -->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

    – Harshil kakadiya
    Nov 22 '18 at 11:26











  • add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

    – Ali
    Nov 22 '18 at 11:27











  • That also doesn't work, the keyboard covers the bottom layout and edittext

    – anangfaturrohman
    Nov 22 '18 at 11:30



















  • Possible duplicate of android:fitsSystemWindows not working

    – Ankur Aggarwal
    Nov 22 '18 at 11:24











  • try same with android:windowSoftInputMode="adjustPan"

    – Chetan Shelake
    Nov 22 '18 at 11:24











  • -->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

    – Harshil kakadiya
    Nov 22 '18 at 11:26











  • add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

    – Ali
    Nov 22 '18 at 11:27











  • That also doesn't work, the keyboard covers the bottom layout and edittext

    – anangfaturrohman
    Nov 22 '18 at 11:30

















Possible duplicate of android:fitsSystemWindows not working

– Ankur Aggarwal
Nov 22 '18 at 11:24





Possible duplicate of android:fitsSystemWindows not working

– Ankur Aggarwal
Nov 22 '18 at 11:24













try same with android:windowSoftInputMode="adjustPan"

– Chetan Shelake
Nov 22 '18 at 11:24





try same with android:windowSoftInputMode="adjustPan"

– Chetan Shelake
Nov 22 '18 at 11:24













-->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

– Harshil kakadiya
Nov 22 '18 at 11:26





-->> android:windowSoftInputMode="adjustResize" <--to your parent view in your activity.

– Harshil kakadiya
Nov 22 '18 at 11:26













add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

– Ali
Nov 22 '18 at 11:27





add this line in Manifest : android:windowSoftInputMode="stateHidden|adjustResize" AND this line in add in activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); above setContentView(R.layout.activity_main);

– Ali
Nov 22 '18 at 11:27













That also doesn't work, the keyboard covers the bottom layout and edittext

– anangfaturrohman
Nov 22 '18 at 11:30





That also doesn't work, the keyboard covers the bottom layout and edittext

– anangfaturrohman
Nov 22 '18 at 11:30












1 Answer
1






active

oldest

votes


















1














Change



android:layout_height="match_parent"


in your ScrollView to



android:layout_height="wrap_content"


Works on my test example of your code






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429733%2fautomatically-adjusts-layout-when-the-keyboard-is-shown%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Change



    android:layout_height="match_parent"


    in your ScrollView to



    android:layout_height="wrap_content"


    Works on my test example of your code






    share|improve this answer




























      1














      Change



      android:layout_height="match_parent"


      in your ScrollView to



      android:layout_height="wrap_content"


      Works on my test example of your code






      share|improve this answer


























        1












        1








        1







        Change



        android:layout_height="match_parent"


        in your ScrollView to



        android:layout_height="wrap_content"


        Works on my test example of your code






        share|improve this answer













        Change



        android:layout_height="match_parent"


        in your ScrollView to



        android:layout_height="wrap_content"


        Works on my test example of your code







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 11:37









        ManxDevManxDev

        6819




        6819
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429733%2fautomatically-adjusts-layout-when-the-keyboard-is-shown%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory