【发布时间】:2014-04-23 09:20:02
【问题描述】:
在 Android 4.4 上,当使用带有 ActionBarCompat 和 NavigationDrawer 的半透明状态栏选项时,NavigationDrawer 列表视图与 ActionBar 略有重叠。它适用于我测试过的所有其他 API 级别。
据我所知,这是因为marginTop 选项从屏幕顶部而不是操作栏顶部(状态栏底部)开始。
状态栏的底部。有一个偏移量
有解决方法吗?我正在使用示例布局并将marginTop 当前设置为?attr/actionBarSize。
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="@drawable/bg_app" />
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
-
你找到解决办法了吗?
标签: android android-actionbar navigation-drawer