0

In some of the fragments in my app I have an EditText on the bottom of the page. The problem with this is that when the keyboard opens, the keyboard overlaps the bottom of the page so you can't see the EditText. Is it possible to align the bottom of the FrameLayout, which contains the Fragments, to the top of the keyboard?

The view of the Activity containing the FrameLayout:

<?xml version="1.0" encoding="utf-8"?>
<com.myapp.Layouts.FullDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity_">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include layout="@layout/view_toolbar" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/content_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/view_menu_bar" />

            <include layout="@layout/view_menu_bar"
                android:layout_height="@dimen/menu_bar_height"
                android:layout_width="fill_parent"
                android:layout_alignParentBottom="true"
                android:id="@+id/view_menu_bar" />
        </RelativeLayout>
    </LinearLayout>

    <include layout="@layout/view_drawer"
        android:id="@+id/drawer"
        />

</com.myapp.Layouts.FullDrawerLayout>
Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56

3 Answers3

0

Find the activity in your manifest.xml and set android:windowSoftInputMode="adjustResize" something like:

<activity android:name=".YourActivity"
          android:windowSoftInputMode="adjustResize">
</activity>

Source: http://android-developers.blogspot.in/2009/04/updating-applications-for-on-screen.html

Vitaly Zinchenko
  • 4,871
  • 5
  • 36
  • 52
0

try:

<activity
    android:windowSoftInputMode="adjustPan"/>

or:

<activity
    android:windowSoftInputMode="adjustResize"/>
tiny sunlight
  • 6,231
  • 3
  • 21
  • 42
  • AdjustPan just moves the whole page up instead of just the height of the FrameLayout. AdjustResize isn't doing anything. – Bart Bergmans Nov 09 '15 at 14:06
  • Isn't it a solution?You can use FrameLayout.setTranslateY() to move the framelayout . – tiny sunlight Nov 09 '15 at 14:16
  • But I also need the possibility to scroll further down when the keyboard is open. So I need the FrameLayout to align to top of the screen and the top of the keyboard when the keyboard is open. – Bart Bergmans Nov 09 '15 at 14:20
  • I want to know why adjustResize did nothing. – tiny sunlight Nov 09 '15 at 14:27
  • Why did you think that AdjustResize isn't doing anything? I think it did what it need to do .But you didn't find it!If you want to scroll , you need a scrollview in the fragment. – tiny sunlight Nov 09 '15 at 14:33
  • I have a scrollview in the fragment but the EditText is still hidden behind the keyboard when using adjustResize. When using adjustPan the EditText is shown but you can't scroll down to see the field below the selected field. – Bart Bergmans Nov 09 '15 at 14:42
  • when using resize,u cant scroll with you finger? – tiny sunlight Nov 09 '15 at 14:57
  • Well, it doesn't really resize. It just puts the keyboard over the content. But I'm now trying to copy some stuff from my other apps where this problem doesn't occur. – Bart Bergmans Nov 09 '15 at 15:03
  • The only difference between this app and my other apps is that I am opening the keyboard from a fragment. – Bart Bergmans Nov 09 '15 at 15:07
  • http://stackoverflow.com/questions/7417123/android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible . Try this. – tiny sunlight Nov 09 '15 at 15:10
  • And this.http://stackoverflow.com/questions/21092888/windowsoftinputmode-adjustresize-not-working-with-translucent-action-navbar – tiny sunlight Nov 09 '15 at 15:11
0

It appears to be a bug where adjustResize won't work when you open the keyboard from a fragment. I fixed it by using the code from android:windowSoftInputMode="adjustResize" doesn't make any difference? / https://github.com/mikepenz/MaterialDrawer/blob/master/library/src/main/java/com/mikepenz/materialdrawer/util/KeyboardUtil.java

Community
  • 1
  • 1
Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56