软键盘隐藏工具栏

2024-03-19

我在布局中使用了工具栏。每当我打开活动并关注编辑文本时,它都会隐藏工具栏。请看下面的图片

下面是我的布局文件:

<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.sampleactivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="4dp"
    android:background="@color/color_theme"
    android:minHeight="?attr/actionBarSize">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="App"
        android:textColor="@color/white"
        android:textSize="24sp" />

    <Button
        android:id="@+id/past_locations"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="Next"
        android:textColor="@color/white"
        style="?android:attr/borderlessButtonStyle"/>

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

<LinearLayout
    android:id="@+id/mapLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>


    <EditText
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Title"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:singleLine="true"
        />

    <AutoCompleteTextView
        android:id="@+id/tags"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:maxLines="3"
        />

</LinearLayout>

Using android:windowSoftInputMode="adjustPan"也没有帮助。

当键盘打开时,如何避免隐藏工具栏。


Adding android:windowSoftInputMode="adjustResize"AndroidManifest.xml 解决了我的问题,例如:

 <activity
        android:name=".MainActivity"
        android:label="@string/activity_main"
        android:windowSoftInputMode="adjustResize">
 </activity>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

软键盘隐藏工具栏 的相关文章

随机推荐