Android 隐藏焦点处的工具栏编辑文本问题

Android 隐藏焦点处的工具栏编辑文本问题,android,xml,Android,Xml,我正在聊天活动中使用应用程序中的android.support.v7.widget.Toolbar。但一旦编辑文本焦点和键盘打开,工具栏就会隐藏 这是我的xml代码: app_bar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="h

我正在聊天活动中使用应用程序中的android.support.v7.widget.Toolbar。但一旦编辑文本焦点和键盘打开,工具栏就会隐藏

这是我的xml代码: app_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/primaryColor"
android:minHeight="?attr/actionBarSize"
app:theme="@style/myCustomToolBarTheme"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" >

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

activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ccc"
android:orientation="vertical" >

<include
    android:id="@+id/app_bar"
    layout="@layout/app_bar" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/app_bar" >

        <ListView
            android:id="@+id/my_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:ems="10" >

            <requestFocus />
        </EditText>
    </RelativeLayout>

</RelativeLayout>

输出屏幕:


请帮助我。

据我所知,您的问题是什么,当您尝试在此编辑文本中键入内容时,我认为您的布局正在向上移动。因此,我的解决方案是: 将工具栏以外的所有内容包装成单一布局,并放入scrollview中。 然后,当你们打字时,工具栏将保持不变,页面内容将可滚动。 请尝试以下代码:

<include
        android:id="@+id/app_bar"
        layout="@layout/app_bar" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/app_bar"
    android:fillViewport="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/second_activity"
            android:textColor="#000"/>

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:ems="10">

            <requestFocus/>
        </EditText>
    </RelativeLayout>
</ScrollView>

刚刚设置好

  <item name="android:windowFullscreen">false</item>
false

在样式中。然后将视图放在滚动视图下。

谢谢您的回答,但您能在这里发布一个实用代码吗。冷,您能告诉我有什么问题吗?我使用了这段代码,它正在工作Bro,同样的问题也发生了。很抱歉,这是关于列表视图的,不是在列表视图中设置聊天信息的正常视图。