软键盘隐藏动作栏

hen*_*000 25 android android-softkeyboard android-activity android-actionbar android-appbarlayout

我有一个简单的活动,文本视图后跟两个编辑文本.当我开始输入时,软键盘会向上推动布局并隐藏操作栏,我将无法选择/复制/粘贴文本.

我的活动如下:

正常活动视图

当我开始输入时,操作栏会被隐藏,就像这样 - 更重要的是,请注意,即使文本突出显示,也会丢失正常的复制粘贴栏:

缺少操作栏和复制/粘贴栏

我该怎么做才能确保操作栏不隐藏?

  • 我已经尝试了一些来自SO的其他技巧(例如使用滚动视图),但没有一个工作.
  • 该应用程序是使用带有抽屉活动的Android Studio 1.4.1向导创建的.
  • 在我的活动清单中,我使用的是adjustPan.我不想使用adjustResize.

    android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

我的活动在这里:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/navigation_drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".MainActivity">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/app_theme.app_bar_overlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/app_theme.popup_overlay" />

        </android.support.design.widget.AppBarLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/activity_margin"
            android:fillViewport="true"
            android:orientation="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:background="@android:color/darker_gray"
                android:text="My holiday story here." />

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/activity_margin" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/gap_normal"
                android:gravity="top"
                android:text="My Holiday in Europe" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:gravity="top"
                android:text="My holiday story is blah blah blah blah blah blah blah blah blah..." />

        </LinearLayout>


    </android.support.design.widget.CoordinatorLayout>

    <com.magicparcel.app.mysampleapp.ui.CustomNavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/navigation_drawer_header"
        app:itemIconTint="@color/app_grey_500"
        app:menu="@menu/drawer_main" />

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

Utt*_*ara 6

尝试添加app:layout_collapseMode="pin"工具栏

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/app_theme.popup_overlay" />
Run Code Online (Sandbox Code Playgroud)

并允许复制/粘贴在EDITTEXT Set android:textIsSelectable="true"看起来更上https://developer.android.com/guide/topics/text/copy-paste.html