android studio编程时出现的错误:you need to use a theme.appCompat theme(or descendant) with this a

来源:互联网 发布:大数据采集系统源代码 编辑:程序博客网 时间:2024/06/03 13:18

用Android Studio中设置activity的theme时候出现的问题:

java.lang.illegalStateException : you need to use a theme.appCompat theme(or descendant) with this activity.


出现这种问题原因是:你的布局xml文件有 support-V7 上的控件而你的AndroidManifest里的该activity的theme名字写成这种形式(或者其他形式),如:
<style name="translucent"> (错误写法)

正确的是<style name="translucent">里的name要前要添加 AppTheme,如:
<style name="AppTheme.translucent"> (正确写法)

【否则会报出这种错误:You need to use a Theme.AppCompat theme (or descendant) with the design library.】


如(AndroidManifest.xml):
        <activity        android:name=".ui.activity.NewsCommentActivity"        android:theme="@style/AppTheme.translucent" />

 
translucent是我在style.xml写的一个stlye,如:
    <style name="AppTheme.translucent" >        <item name="windowActionBar">false</item>        <item name="windowNoTitle">true</item>    </style>


0 0
原创粉丝点击