3

I am developing an Android app in full screen mode. I want the screen automatically adjusted when a soft input is shown. I am using ScrollView to make my screen can extend larger than the maximum height. You can see the layout XML below:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="${packageName}.${activityClass}" >

    <VideoView
        android:id="@+id/taskdetail_bgvideo"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

    <ScrollView
        android:id="@+id/taskdetail_scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

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

            <!-- Other Widgets -->

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

The VideoView in the background is placed as intended to create a background video in the overall layout.

I tried the workaround in Android How to adjust layout in Full Screen Mode when softkeyboard is visible but somehow in my case, it doesn't work as expected. When I choose the bottommost TextView, all screen somehow pushed upwards to the top, leaving a very big black area between soft keyboard and the activity screen. Check the screenshot below (Sorry, still low reputation, so cannot post the image directly :( )

Giant blackhole

So do you have any possible idea to tackle this weird behavior? In addition, I also have tried setting the softInputMode to ADJUST_RESIZE or ADJUST_PAN, and both settings did that. When I set it to ADJUST_NOTHING, nothing really adjusted at all.

When I don't use the workaround I mentioned above, I cannot scroll the view to the bottommost widget, but somehow the window view is panned to the focused TextView. I believe that this is actually the major culprit, but I don't know how to fix it.

Thanks in advance :)

Community
  • 1
  • 1
Gilang
  • 191
  • 1
  • 7

4 Answers4

9

If you have the property <item name="windowFullscreen">true</item> in your theme then the android:windowSoftInputMode="adjustResize" doesn't work.

kassim
  • 3,880
  • 3
  • 26
  • 27
0

Try change

<ScrollView
    android:id="@+id/taskdetail_scroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

to

<ScrollView
    android:id="@+id/taskdetail_scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
Igor Morais
  • 645
  • 1
  • 8
  • 13
-1

Try to add below properties to your <activity tag declaration in AndroidManifest.xml

android:windowSoftInputMode="stateHidden|adjustPan"
Mohit Jain
  • 30,259
  • 8
  • 73
  • 100
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • Unfortunately it does not work as I expected. I don't want to pan the screen when the keyboard is shown. I want it to resize the activity screen size to the usable area above soft keyboard. But because the activity is in Full Screen, the adjustResize will not work. – Gilang May 12 '14 at 17:16
-1

you have to write

android:windowSoftInputMode="stateHidden|adjustPan"

in your manifest file

Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59