【发布时间】:2016-03-30 19:04:09
【问题描述】:
我在 Android Studio 1.4 中创建 Navigation Drawer Activity 后,IDE 自动生成了一些 xml 文件。
现在有一个问题:
布局编辑器中的图形预览可能不准确: - 不支持 PorterDuff 滤色器。
这是我的 activity_navi.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_navi"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_navi"
app:menu="@menu/activity_navi_drawer" />
</android.support.v4.widget.DrawerLayout>
我尝试从 activity_navi.xml 中删除这些行,并且预览效果很好:
<include layout="@layout/app_bar_navi" android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView android:id="@+id/nav_view"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_gravity="start" android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_navi" app:menu="@menu/activity_navi_drawer" />
我刚刚发现如果我在布局预览中将 API 级别更改为 20 或 21,问题就消失了!在我选择 API 19 之前。
有人知道如何解决这个问题吗?
【问题讨论】: