我在使用Google地图API时遇到了一个问题,当软键盘出现时无法调整列表视图的大小。基本上我将地图覆盖整个屏幕,透明ActionBar,并在右侧滑动碎片中显示一系列车辆。当右侧面板展开时,整个布局如下所示:
现在我正在使用
这不好,因为我无法看到整个车辆列表。我已经尝试使用
。
我可以看到整个ListView,并且它可以很好地滚动,但是我的EditText现在位于ActionBar下方。基本上,我想要实现两种情况的组合,使其看起来像这样:
。现在这是带有我的列表的碎片的布局。
这是我的MainActivity的布局。
![enter image description here](https://istack.dev59.com/HsdVb.webp)
android: windowSoftInputMode="adjustPan"
,因此当我聚焦于EditText并弹出键盘时,它看起来像这样:![enter image description here](https://istack.dev59.com/TtjyM.webp)
android:windowSoftInputMode="adjustResize"
,但由于我使用了透明ActionBar,因此会出现以下情况:![enter image description here](https://istack.dev59.com/4DJWb.webp)
我可以看到整个ListView,并且它可以很好地滚动,但是我的EditText现在位于ActionBar下方。基本上,我想要实现两种情况的组合,使其看起来像这样:
![enter image description here](https://istack.dev59.com/iJIpx.webp)
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@drawable/bg"
tools:context="hidden">
<EditText
android:id="@+id/vehicle_search_edit_text"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:focusable="true"
android:hint="Search"
android:imeOptions="actionSearch"
android:singleLine="true" />
<ListView
android:id="@+id/list_vehicles"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/vehicle_search_edit_text"
android:animateLayoutChanges="true"
android:fastScrollEnabled="true"
/>
</RelativeLayout>
这是我的MainActivity的布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/layout_root_map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/layout_root_vehicles"
android:layout_width="350dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
<RelativeLayout
android:id="@+id/layout_root_settings"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
我熟悉通过编程设置布局高度,因为我已经在嵌套列表片段的布局中这样做了。ActionBar必须保持透明,因为那是我的老板想要的。