【发布时间】:2014-10-21 11:49:58
【问题描述】:
当存在软件键盘时,我在调整列表视图大小时遇到了一点问题。基本上我使用的是谷歌地图 API,其中地图覆盖了整个屏幕,带有透明的操作栏,并且我有一个从右侧滑入的片段中存在于地图上的车辆列表。当右侧面板出现时,整个布局如下所示:
现在我使用的是android:windowSoftInputMode="adjustPan",所以当我聚焦编辑文本并且键盘滑出时,它看起来像这样:
这不好,因为我看不到完整的车辆列表。我曾尝试使用android:windowSoftInputMode="adjustResize",但由于我使用的是透明操作栏,因此会发生这种情况:
我可以看到整个 listView 并且它滚动得很好,但是我的 EditText 现在位于 ActionBar 下。基本上我想要实现的是两种情况的结合,所以它看起来像这样:
现在这是我的列表的片段布局
<?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>
我熟悉以编程方式设置布局的高度,因为我已经在使用嵌套了 listfragment 的布局。 ActionBar 必须保持透明,因为这是我老板想要的。
【问题讨论】:
标签: android android-layout android-fragments android-listview