首页 > 解决方案 > “索引:0,大小:0 查看绘制错误”Android Studio 设计选项卡错误

问题描述

我最近将我的 AS 更新到 4.0 版本。之后,我在布局中放置了一个 EditText 和一个 TextView,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:text="EditText should be below me!"
        android:textSize="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="I'm a hint"/>

</LinearLayout>

但是,设计选项卡根本没有向我显示 EditText! 没有输入字段的设计选项卡

在屏幕截图的底部,您可以看到错误。谷歌搜索对我没有帮助,我发现的所有内容都是Design in Android studio error Index:0 size:0.... 查看 draw failed问题,没有答案。

我已经做了什么

我使缓存无效并重新启动了我的 AS,但它没有帮助。此外,我已将应用程序的主题从

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

没有影响。但是,一旦我设法将其更改为按钮元素样式之类的东西并且它起作用了,即使它不是我正在寻找的解决方案。如果我明确地将 EditText 的样式更改为类似

@style/Widget.AppCompat.Button.ButtonBar.AlertDialog

或者

@style/Widget.AppCompat.Button.Borderless

我可以看到编辑文本...

我会很感激你给我的任何帮助,伙计们。提前致谢!

更新

可以通过在 AS 的设置中打开“使用新的布局渲染引擎”来解决这个问题。

使固定

无论如何,我希望我们能够找到并修复它,伙计们。感谢您的关注!

标签: androidandroid-studioandroid-layout

解决方案


推荐阅读