Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:windowSoftInputMode="adjustResize" doesn't make any difference?

I have a faux dialog which uses this layout:

<?xml version="1.0" encoding="utf-8"?> <FrameLayout    xmlns:android="http://schemas.android.com/apk/res/android"                 android:layout_height="match_parent"                 android:layout_width="match_parent"                 android:id="@+id/containerPageConatiner">      <FrameLayout    android:id="@+id/dialogHolder"                     android:layout_height="wrap_content"                     android:layout_width="wrap_content"                     android:padding="15dp"                     android:layout_gravity="center"                     android:background="@drawable/panel_picture_frame_bg_focus_blue"/>     </FrameLayout>  

I place a fragment inside the <FrameLayout> depending on the dialog which is opening - The activity controlling the Dialog looks like this:

<activity     android:label="@string/app_name"     android:name=".activity.DialogActivity"     android:theme="@style/CustomTheme.Screen.Transparent"      android:windowSoftInputMode="adjustResize"> 

Unfortunately when you click on an edit text inside of the dialog, no resizing takes place. The windowSoftInputMode literally makes no difference as the functionality is the same as pan mode.

Documentation says "This of course only works for applications that have a resizeable area that can be reduced to make enough space" but doesn't tell you what it means by "a resizeable area" and makes me think that in some way I don't have a resizeable area?

If anyone knows what's up can they help me out?

EDIT

Surrounding the dialog like so doesn't change anything:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/containerPageConatiner"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >      <View         android:layout_width="0dp"         android:layout_height="0dp"         android:layout_weight="1" />      <FrameLayout             android:id="@+id/dialogHolder"         android:layout_height="wrap_content"     android:layout_width="wrap_content"         android:padding="15dp"         android:layout_gravity="center"         android:background="@drawable/panel_picture_frame_bg_focus_blue"/>      <View         android:layout_width="0dp"         android:layout_height="0dp"         android:layout_weight="1" /> </LinearLayout> 

EDIT2

Scrollview as parent doesn't help either:

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/containerPageConatiner"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <FrameLayout             android:id="@+id/dialogHolder"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:padding="15dp" />  </ScrollView> 
like image 841
Graeme Avatar asked Dec 06 '11 10:12

Graeme


People also ask

Is it possible to override onapplywindowinsets in fitsystemwindows?

@kcoppock answer is really helpful, but fitSystemWindows was deprecated in API level 20 So since API 20 (KITKAT_WATCH) you should override onApplyWindowInsets

How to change the content of a window based on its insets?

To directly manipulate how your content lays out relative to the system bars (which occupy a space known as the window's "content insets"), override fitSystemWindows (Rect insets). The fitSystemWindows () method is called by the view hierarchy when the content insets for a window have changed, to allow the window to adjust its content accordingly.

Can I use adjustresize with the translucent status bar?

It shouldn't work with the translucent status bar; that setting forces the window into fullscreen mode which does not work with adjustResize. You can either use adjustPan or use the fitsSystemWindows properties. I would suggest reading about the feature though, it has significant side effects:

What does soft_input_adjust_pan actually do?

Actually SOFT_INPUT_ADJUST_PAN seems to be NOT ignored according to my experience - it will move whole screen up, including system bar and shift keyboard under focused view. Thanks - you are correct about the SOFT_INPUT_ADJUST_PAN.


1 Answers

I created a new project in order to try and get the basic features working for window resizing and the slowly moved it towards the target peice of my project. Doing this I tracked the problem down to this:

In my theme hierarchy I had this property:

<item name="android:windowFullscreen">true</item>  

which was burried at the level of Theme.Black.NoTitleBar.FullScreen - An ancestor of my custom theme.

The documentation suggests that this is a "Flag indicating whether this window should fill the entire screen". That sounds like a good thing to have if you have an app which takes up the whole screen... Except it still takes up the whole screen without the flag.

In fact, once you've taken this out, there is absolutely no change in the app at all... apart from adjustResize now works perfectly.

like image 98
Graeme Avatar answered Sep 19 '22 07:09

Graeme