键盘打开时,操作栏会隐藏。如何防止这种情况?

时间:2017-01-14 18:15:24

标签: android layout scrollview android-softkeyboard

我有一个Coordinator Layout,其中包含AppBar Layout和一个Relative Layout

相对布局包含一个ScrollView和一个EditText

首先,每当我用来点击编辑文本输入文字时,键盘打开并隐藏编辑文本字段。 <{1}}位于顶部。

当我在活动的清单中设置ActionBar时,编辑文本字段仍隐藏在键盘后面。屏幕顶部显示android:windowSoftInputMode="adjustResize"

但是当我设置Actionbar时,我的android:windowSoftInputMode="adjustPan"字段在键盘上方可见,但现在Edittext显示在屏幕外。

我希望操作栏始终可见,并编辑键盘上方可见的文本字段。

请帮我解决问题!

content_home.xml

Actionbar

activity_home.xml

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout      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:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_home"
    android:fitsSystemWindows="true">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:isScrollContainer="true">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/text_margin"
            android:text="@string/large_text" />
    </ScrollView>

    <EditText
        android:layout_width="match_parent"
        android:id="@+id/inputText"
        android:background="@drawable/input_edit_text"
        android:layout_height="@dimen/app_input_height"
        android:layout_margin="@dimen/text_margin"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

0 个答案:

没有答案