“以下类无法找到”与布局中的自定义Kotlin视图
问题描述:
我遇到了一个问题,包括XML布局文件中的自定义Kotlin视图。下面的代码:“以下类无法找到”与布局中的自定义Kotlin视图
class CustomView: RelativeLayout {
/**
* Programmatic constructor
*/
constructor(aVariable: Boolean, context: Context): super(context) { ... }
/**
* XML constructor
*/
@JvmOverloads
constructor(context: Context, attributeSet: AttributeSet? = null, defStyle: Int = 0): super(context, attributeSet, defStyle) { ... }
}
和XML:
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.turingtechnologies.materialscrollbar.CustomView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
则布局预览抱怨:
“缺少类 -
以下类找不到: com.turingtechnologies.materialscrollbar.CustomView
(修复构建路径,编辑XML,创建类)”
注:这是AS 3.0的Beta 3
稳定的AS版本的行为是什么? –
@MaximOstrovidov我会看,让你知道 –
代码似乎很好。它可能仅仅是一些AS的滞后。尝试“清理 - >重建”或使缓存失效。 –