Android 布局加载出错

winton_by 2016-03-29 03:29:24
错误信息:
FATAL EXCEPTION: main
Process: com.wasu.winton.phonetv, PID: 4346
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wasu.winton.phonetv/activity.WelcomeActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.


布局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?rootViewBg"
>
<Button
android:id="@+id/bt"
android:text="修改主题"
android:layout_width="match_parent"
android:layout_height="60dp"
/>
<view.CircleProgress
android:id="@+id/circle_progress_welcome"
android:layout_centerInParent="true"
android:layout_width="150dp"
android:layout_height="150dp"
/>

<TextView
android:layout_marginBottom="40dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:typeface="serif"
android:textStyle="bold"
android:text="@string/wasu_phone_tv"
android:textSize="30sp"
android:textColor="?textColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<TextView
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:textColor="@color/white"
android:text="@string/verion_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>

attr 文件:

<resources>

<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
<attr name="rootViewBg" format="color"/>
<attr name="titleBg" format="color"/>
<attr name="buttonBg" format="color"/>
<attr name="textColor" format="color"/>
<attr name="buttonTextColor" format="color"/>

</resources>


style文件
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>

<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
<!--日间模式-->
<style name="Theme_Day" parent="AppTheme">
<item name="rootViewBg">#660099</item>
<item name="textColor">#FFFFFF</item>
<item name="buttonBg">#383838</item>
<item name="buttonTextColor">#008888</item>
</style>
<!--夜间模式-->
<style name="Theme_Night" parent="AppTheme">
<item name="rootViewBg">#006600</item>
<item name="textColor">#000000</item>
<item name="buttonBg">#000090</item>
<item name="buttonTextColor">#008811</item>
</style>


</resources>



想了半天不知道问题出在哪里,哪位高手指点一下
...全文
199 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Birds2018 2016-03-29
  • 打赏
  • 举报
回复
可能是 android:background="?rootViewBg" 这个有问题
winton_by 2016-03-29
  • 打赏
  • 举报
回复
引用 1 楼 birdsaction 的回复:
可能是 android:background="?rootViewBg" 这个有问题
也试过 android:background="?attr/rootViewBg"

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧