【问题标题】:Rendering Problems Exception raised during rendering: <include /> can only be used inside of a ViewGroup渲染过程中出现异常:<include /> 只能在 ViewGroup 内部使用
【发布时间】:2015-05-30 14:22:54
【问题描述】:

我是使用 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>

【问题讨论】:

  • 请发布带有&lt;include/&gt;标签的布局资源。
  • 这是奇怪的部分,没有 或者我看不到它:/

标签: android android-studio rendering


【解决方案1】:

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

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

【讨论】:

  • 请解释一下,它对我有帮助。 +1
【解决方案2】:

感谢那些试图帮助我的人。我已经解决了我的问题,并希望与您分享其他可能遇到相同问题的案例。其实很简单我偶然发现的:D

从上面的栏中选择 Build > Make Module 'app'

就是这样 :D 这解决了我的问题

【讨论】: