【发布时间】:2017-08-09 00:09:53
【问题描述】:
以下是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<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/root_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="tailamade.boop.CustomerHomeActivity"
tools:openDrawer="start">
<include
layout="@layout/content_customer_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/activity_main"
app:menu="@menu/menu_customer_home" />
</android.support.v4.widget.DrawerLayout>
</layout>
我也尝试过像这样编写自己的 CustomDrawerLayout(没有运气):
class CustomDrawerLayout : DrawerLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var widthMeasureSpec = widthMeasureSpec
var heightMeasureSpec = heightMeasureSpec
widthMeasureSpec = MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY)
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY)
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}
}
我看过其他有关此异常的帖子,但“解决方案”不起作用。这里有什么问题?
【问题讨论】:
-
你使用的是什么版本的支持库?
-
发帖供参考:android.googlesource.com/platform/frameworks/support/+/… 不确定对应的库版本。
-
@stkent 支持库版本 26.0.0
标签: android kotlin drawerlayout