android - 渲染问题渲染期间引发异常 : <include/> can only be used inside of a ViewGroup

标签 android android-studio rendering

我是使用 Android Studio 进行开发的新手。所以这就是问题所在: 我打开一个新项目,在触摸或添加代码之前我得到了这个:

“渲染问题渲染期间引发异常:只能在 ViewGroup 内部使用”

所以我使用 Nexus 4 作为 ADV(默认),所以我尝试了其他 ADV 并得到了相同的警告。唯一不发出警告的是 Android Wear Round and Square。

谁能帮帮我?下面是布局代码:

<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"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="Hi"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="22dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:id="@+id/textView" />


    </RelativeLayout>

最佳答案

在 styles.xml 中,在 Theame.AppCompat.Light.DarkActionBar 之前添加 Base

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

关于android - 渲染问题渲染期间引发异常 : <include/> can only be used inside of a ViewGroup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30547294/

相关文章:

android - Unresolved reference : junit4: Android ComposeUI testing

android - flutter 应用程序 : IOS emulator not connecting to Android Studio

在 StackOverflow 上搜索后,CSS 缩放文本仍然模糊

c++ - OpenGL glCreateProgram() 总是返回 1 并删除之前的程序

Java AttributedString,粗体和上标

java - 通过解码 Base64 播放音频

java - libGdx - 图像背景

android - 用户退出 : clearing the default Google account does not cause the account picker to show up in Android app

android - 如何将翻译编辑器条目导出到 Excel?

android - 为什么我不能添加我的项目依赖项?