0

I have a layout where there's two layouts on top of each other. If the keyboard is displayed I want the top layout to take the "brunt" of the resizing and keep the bottom layout unmodified if possible. Is this possible? Example layout below:

<LinearLayout 
  android:layout_height="match_parent" android:layout_width = "match_parent" android:orientation = "vertical">
<LinearLayout 
  android:layout_height="match_parent" android:layout_width = "match_parent"
   android:layout_weight = "1.0">
</LinearLayout>
<LinearLayout 
  android:layout_height="match_parent" android:layout_width = "match_parent"
android:layout_weight = "1.0" android:id="@+id/important_layout">
</LinearLayout></LinearLayout>
ajacian81
  • 7,419
  • 9
  • 51
  • 64

1 Answers1

0

You can check if your keyboard is visible or not programmatically. Find help here . Once you have detected visibility of your keyboard, you can take reference of your specific layout by it's id using findViewById (saying so, you need to have id assigned for each layout you want to play with) and setVisibility of it to View.GONE

<LinearLayout 
    android:id="@+id/layout_1"
    android:layout_height="match_parent" android:layout_width = "match_parent"
    android:layout_weight = "1.0">
</LinearLayout>

In code:

LinearLayout layout1 = (LinearLayout) findViewById(R.id.layout_1);

if(isKeyboardVisisble) {
    layout1.setVisibility(View.GONE);
}

Hope this helps!

Community
  • 1
  • 1
Mithun
  • 2,075
  • 3
  • 19
  • 26
  • I don't necessarily want to hide the top view. I want it to be the only view that gets resized. Right now if the keyboard pops up both views are resized equally. – ajacian81 Jun 05 '15 at 19:33
  • so funny ... but what is the method "isKeyboardVisisble" ? –  Apr 20 '16 at 09:13