0

My Layout

<FrameLayout...>
    <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#fff"
      android:fillViewport="true">

       <RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent">
        ...
          <LinearLayout
             android:id="@+id/make_this_invisible_on_keyboard_visible"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true"
          >
           ...
         </LinearLayout>
    </ScrollView>
    <LinearLayout
             android:id="@+id/make_this_visible_on_keyboard_visible"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true"
          >
           ...
         </
<FrameLayout>

What i want is that the LinearLayout with the id make_this_invisible_on_keyboard_visible Will be covered by the keyboard when The Keyboard is visible.

on the other hand the layout with id make_this_visible_on_keyboard_visible should be visible.

Current state: both layout are visible

Is it possible or should i rethink my layout design?

royB
  • 11,685
  • 14
  • 48
  • 77
  • Currently i'm using the solution: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android to check if keyboard is visible but would prefer some other solution – royB Jan 06 '15 at 20:23

1 Answers1

0

You will have to impliment onConfigurationChanged method in your activity

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) {
        // set visibility gone
    } else if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES){
        //set Visibility visible
    }
}
Simar
  • 600
  • 4
  • 14
  • I think your answer is not safe: http://stackoverflow.com/questions/6279771/onconfigurationchanged-not-firing-for-keyboardhidden – royB Jan 06 '15 at 19:55
  • although you would have to write code regarding hard keyboard but that's a piece of cake. You could use a combination of Configuration.KEYBOARDHIDDEN___ and Configuration.HARDKEYBOARDHIDDEN___ – Simar Jan 06 '15 at 20:00
  • Sorry it's not working, i've just tested it. also i prefer to deal with configurations change and let android handle it for me. but anyhow it's not working – royB Jan 06 '15 at 20:05