2015-06-04 77 views
0

我有一个布局,其中有两个布局在彼此顶部。如果显示键盘,我希望顶层布局能够承担调整大小的“首要任务”,并尽可能保持底部布局不被修改。这可能吗?下面 示例布局:当Android软键盘可见时隐藏特定视图

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

回答

0

您可以检查键盘是否可见或不编程。寻求帮助here。一旦你发现你的键盘的知名度,你可以把你的具体布局的参考用它的使用findViewById(这么说的话,你需要指定你要玩每个布局id)和它setVisibilityView.GONE

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

在代码:

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

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

希望这有助于!

+0

我不一定要隐藏顶视图。我希望它成为调整大小的唯一视图。现在,如果键盘弹出,则两个视图的大小都相同。 – ajacian81

+0

太好笑了......但“isKeyboardVisisble”的方法是什么? – delive