键盘弹出后视图未调整大小

3

我遵循 Android 指南来使键盘将我的视图对齐到底部。但仍然无法调整视图的大小。您能指导我可能出了什么问题吗?

XML:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.app.Test"
    android:background="@android:color/white">
    <View
        android:id="@+id/statusBarBg"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/toolbarPaddingTop"
        android:background="@color/testColor"/>
    <include
        android:layout_below="@id/statusBarBg"
        android:id="@+id/tool_bar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        />
    <EditText
        android:layout_width="fill_parent"
        android:id="@+id/crack_message"
        android:gravity="top|start"
        android:textSize="30sp"
        android:scrollbars="vertical"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine|textCapSentences"
        android:maxLength="300"
        android:maxLines="10"
        android:layout_below="@id/tool_bar"
        android:layout_marginBottom="50dp"/>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true">
        <ImageView
            android:layout_width="30dp"
            android:layout_height="40dp"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/transparent"
            android:src="@drawable/photo_icon"
            android:scaleType="fitCenter"
            android:layout_marginLeft="15dp"
            android:id="@+id/photoView" />
        <com.app.general.textview.TextViewRegular
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:text="300"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:gravity="center_vertical|center_horizontal"
            android:textSize="20sp"
            android:textColor="#267158"
            android:id="@+id/letters_counter" />

        <Button
            android:layout_width="60dp"
            android:layout_height="fill_parent"
            android:id="@+id/takePhoto"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/transparent" />
    </RelativeLayout>

</RelativeLayout>

清单文件:

<activity
        android:name=".Test"
        android:label="@string/title_activity_test"
        android:windowSoftInputMode="adjustResize" >
    </activity>

结果是键盘覆盖了底部相对布局。

你想将哪个视图与键盘顶部对齐? - KodyVanRy
@DuhProgrammer13 XML底部的RelativeLayout包含相机图标和TextView。 - Dmitrii G.
1
android:windowSoftInputMode="stateVisible|adjustResize" - KodyVanRy
@DuhProgrammer13 我已经设置了adjustResize,并且添加stateVisible也没有改变任何东西。你有一些可用的代码示例,这样我就可以测试它吗? - Dmitrii G.
1个回答

1

Android中的Bug。在使用半透明状态栏时会出现问题。解决方法是在父布局中添加以下属性:

android:fitsSystemWindows="true"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接