Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使视图组被键盘覆盖_Android_Android Layout - Fatal编程技术网

Android 使视图组被键盘覆盖

Android 使视图组被键盘覆盖,android,android-layout,Android,Android Layout,我的布局 <FrameLayout...> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" android:fillViewport="true"> <RelativeLayout android:la

我的布局

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

...
...
...

您必须在活动中实施OnConfiguration Changed方法

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

我认为你的答案是不安全的:虽然你必须写关于硬键盘的代码,但那是小菜一碟。你可以结合使用Configuration.KEYBOARDHIDDEN和Configuration.HARDKEYBOARDHIDDEN。很抱歉,它不起作用,我刚刚测试过。此外,我更喜欢处理配置的变化,让安卓为我处理。但无论如何,它不工作,目前我正在使用的解决方案:检查键盘是否可见,但更喜欢其他解决方案