软键盘隐藏工具栏或编辑文本

时间:2017-01-30 08:27:49

标签: android android-studio toolbar window-soft-input-mode

我遇到类似的问题: Soft Keyboard Hides Toolbar

然后我尝试使用: android:windowSoftInputMode="adjustPan" 它工作,我的edittext出现了,但我的工具栏消失了。

然后我尝试使用: android:windowSoftInputMode="adjustResize" 它使我的工具栏出现,但我的edittext消失了。

如何同时显示工具栏和eddittext?

这里有一些图片:

正常:

enter image description here

使用:android:windowSoftInputMode="adjustPan"

enter image description here

使用:android:windowSoftInputMode="adjustResize"

enter image description here

这是我的主要xml:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include
        layout="@layout/toolbar"
        android:fitsSystemWindows="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@+id/flContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nvView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@android:color/white"
    app:menu="@menu/drawer_view"
    app:headerLayout="@layout/nav_header"/>
 </android.support.v4.widget.DrawerLayout>

这是我的片段:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
    android:id="@+id/todo_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_above="@+id/add_button" />

<Button
    android:id="@+id/add_button"
    android:text="Add"
    android:textSize="20dp"
    android:layout_gravity="bottom|end"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:hint="Enter to-do activity"
    android:textSize="20dp"
    android:ems="10"
    android:id="@+id/todo_edit"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_toLeftOf="@+id/add_button"
    android:layout_toStartOf="@+id/add_button" />


</RelativeLayout>

请帮助我,请向我解释......

0 个答案:

没有答案
相关问题