Android的工作室布局编辑器无法呈现自定义视图自定义、视图、编辑器、布局

2023-09-06 01:39:50 作者:不美如何

在Android的工作室,布局编辑器无法在XML preVIEW自定义视图。

In Android Studio, the layout editor cannot preview custom views in xml.

很简单的例子:

public class MyCustomView extends FrameLayout {
    public MyCustomView(Context context) {
        super(context);
    }

    public MyCustomView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyCustomView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
}

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <com.myprojectxxx.view.MyCustomView
        android:layout_width="48dp"
        android:layout_height="48dp" />

</LinearLayout>

Android的工作室总是说,

Android Studio always says,

渲染问题。

以下类不能被找到:

   com.myprojectxxx.view.MyCustomView(修正构建路径,创建类)   

提示:尝试建立项目

当然,我有课。如果我点击创建类,它抱怨说,同一类已经存在。如果我重建项目,没有什么变化。

Of course, I HAVE that class. If I click "Create Class", it complains that the same class already exists. If I rebuild that project, nothing changes.

和,是的,项目工作得非常好我的Andr​​oid设备上。此外,它呈现相当不错,在Eclipse的ADT。然而,在Android的工作室,它总是说,班班找不到。

And, yes, the project works very well on my Android device. Also, it is rendered very well in Eclipse ADT. However, in Android Studio, it always says that "CLASSES COULD NOT BE FOUND."

Android的工作室不具备的能力,以preVIEW自定义视图的xml文件?有什么问题呢?

Android Studio does not have the ability to preview a xml file with custom views? What's wrong with this?

推荐答案

应该是固定由下面的提交。

Should be fixed by the following commit.

https://android-review.googlesource.com/#/c/59090 /