2017-08-27 89 views
2

我遇到了一個問題,包括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

+0

穩定的AS版本的行爲是什麼? –

+0

@MaximOstrovidov我會看,讓你知道 –

+0

代碼似乎很好。它可能僅僅是一些AS的滯後。嘗試「清理 - >重建」或使緩存失效。 –

回答