Android的工作室布局编辑器无法呈现自定义视图 [英] Android Studio layout editor cannot render custom views

查看:1742
本文介绍了Android的工作室布局编辑器无法呈现自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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 /

这篇关于Android的工作室布局编辑器无法呈现自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆