在Android Studio中,布局编辑器无法在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);
}
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
Android Studio总是说,
渲染问题
找不到以下类:
- com.myprojectxxx.view.MyCustomView(修复构建路径,创建类)
提示:尝试构建项目
当然,我有那门课.如果我单击"创建类",它会抱怨同一个类已经存在.如果我重建该项目,没有任何改变.
而且,是的,该项目在我的Android设备上运行良好.此外,它在Eclipse ADT中呈现得非常好.但是,在Android Studio中,它总是说"CLASSES可能无法找到".
Android Studio无法使用自定义视图预览xml文件?这有什么问题?
java android android-custom-view android-layout android-studio
更新 android studio dolphin后,我的旧项目 xml 预览不显示视图。有人面临同样的问题吗?并已完成解决方案,请在这里分享。它运行得很好,但预览不起作用。
我做了什么尝试?
但这些都没有解决我的问题。

我已将我的 Android studio 更新到新的 Dolphin 2021.3.1 版本。但更新 Android studio 后布局预览不起作用。它显示空白屏幕。如果有人解决这个问题请帮我解决这个问题。
android android-layout android-studio android-layout-editor android-studio-dolphin