当Android软键盘可见时隐藏特定视图

当Android软键盘可见时隐藏特定视图,android,android-layout,layout,Android,Android Layout,Layout,我有一个布局,其中有两个布局相互重叠。如果显示键盘,我希望顶部布局承受调整大小的“冲击”,并尽可能保持底部布局不变。这可能吗? 布局示例如下: <LinearLayout android:layout_height="match_parent" android:layout_width = "match_parent" android:orientation = "vertical"> <LinearLayout android:layout_height="mat

我有一个布局,其中有两个布局相互重叠。如果显示键盘,我希望顶部布局承受调整大小的“冲击”,并尽可能保持底部布局不变。这可能吗? 布局示例如下:

<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>

您可以通过编程检查键盘是否可见。寻求帮助。一旦检测到键盘的可见性,就可以使用
findViewById
(这样说,您需要为要玩的每个布局分配
id
)并
setVisibility
将其设置为
视图。消失了

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

希望这有帮助

我不一定要隐藏顶视图。我希望它是唯一一个调整大小的视图。现在,如果键盘弹出,两个视图的大小将相等。真有趣。。。但是“isKeyboardVisisble”的方法是什么?
LinearLayout layout1 = (LinearLayout) findViewById(R.id.layout_1);

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