Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.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 安卓:键盘打开时会显示Tablayout_Android_Android Softkeyboard_Android Tablayout_Window Soft Input Mode - Fatal编程技术网

Android 安卓:键盘打开时会显示Tablayout

Android 安卓:键盘打开时会显示Tablayout,android,android-softkeyboard,android-tablayout,window-soft-input-mode,Android,Android Softkeyboard,Android Tablayout,Window Soft Input Mode,我正在使用TabLayout,它位于屏幕底部。问题是 当键盘打开时,表格布局也会出现在键盘上方 我想躲在键盘后面 在清单中,我设置了android:WindowsOfInputMode=“adjustResize”,如果我更改为adjustSpan,甚至当键盘打开时,平铺条也会向上 布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/a

我正在使用TabLayout,它位于屏幕底部。问题是 当键盘打开时,表格布局也会出现在键盘上方

我想躲在键盘后面

在清单中,我设置了android:WindowsOfInputMode=“adjustResize”,如果我更改为adjustSpan,甚至当键盘打开时,平铺条也会向上

布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingPrefix"
android:orientation="vertical">

  <android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="@color/white"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:elevation="0dp">

    <android.support.v7.widget.Toolbar
        android:id="@+id/tb_toolbar_main_activity"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/transparent"
        app:layout_scrollFlags="enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tb_heading"
                fontPath="@string/font_bebas_neue_bold"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="15dp"
                android:layout_marginRight="15dp"
                android:text="@string/app_name_caps"
                android:textAlignment="center"
                android:textColor="@color/heading_color"
                android:textSize="@dimen/toolbar_title_text" />

        </LinearLayout>
    </android.support.v7.widget.Toolbar>


</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
    android:id="@+id/vp_activity_main"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:background="@color/white"/>

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabBackground="@drawable/tab_back_selected"
    app:tabIndicatorHeight="0dp"
    app:tabMode="fixed"
    app:tabGravity="fill"
    app:tabSelectedTextColor="@android:color/white"
    app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
    app:tabTextColor="@color/home_sub_text"
    />


我也面临同样的问题,我通过添加以下代码解决了这个问题。请试试这个

在build.gradle文件中

implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.2.1'
在Manifest.xml中

  android:windowSoftInputMode="adjustResize"
活动课

TabLayout tabs = findViewById(R.id.tabs);

KeyboardVisibilityEvent.setEventListener(
                MainActivity.this,
                new KeyboardVisibilityEventListener() {
                    @Override
                    public void onVisibilityChanged(boolean isOpen) {
                        if(isOpen){
                            tabs.setVisibility(View.GONE);
                        } else {
                            tabs.setVisibility(View.VISIBLE);
                        }
                    }
                });

在清单中添加android:WindowsOfInputMode=“adjustPan | adjustNothing”

尝试将相对布局作为父布局,并将tablyout属性设置为alignparentbottom=true

将另一个布局放置在此表格布局上方


希望这会有所帮助。

相反,将相对布局作为父布局,然后为tablayout属性alignparentbottom=true。把另一个布局放在上面。希望这会有所帮助。这个解决方案是可行的,但这是一种修补,我们知道原因是什么吗。我不知道这个解决方案会不会导致任何其他问题不,这个解决方案不会在您的屏幕布局或代码中导致任何其他问题。不管怎样,它都能正常工作。我在我的一些项目中使用相同的解决方案。@BinilSurendran,如果这个答案对你有帮助,那么你能帮助我获得进入这个社区的特权吗。提前感谢,我无法将其更改为相对布局,因为如果您尝试调整标签,将出现闪烁问题windowsoftinoutmode@MiniChip:请分享一些例子。这是一种不起作用的方式。选项卡会随着键盘继续向上移动。当键盘打开时,这将导致平铺栏也向上移动
android:windowSoftInputMode="adjustPan"