Android--You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
来源:互联网 发布:淘宝产品拍摄价格表 编辑:程序博客网 时间:2024/05/17 01:30
一:错误场景
自定义一个Activity的theme;而这个Activity继承自v7包中的AppCompatActivity或者ActionBarActivity:在Activity中指定相应的theme:
android:theme="@style/Transparent"
配置相应的styles.xml:
<style name="Transparent" parent="AppTheme.Base"> <item name="android:windowBackground">@color/transparent</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item></style>
二:代码错误
You need to use a Theme.AppCompat theme (or descendant) with this activity.
三:解决方案:
1 --:继承自Activity即可
----:无法兼容老版本样式
----:无法实现5.0的MaterialDesign效果
2 --:
--1:在res/values/styles.xml:
添加一个样式为AppTheme.Base,然后Transparent继承自AppTheme.Base
<style name="Transparent" parent="AppTheme.Base"> // 此处写自己的代码</style><style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowBackground">@android:color/white</item></style>
--2:新建values-v21文件夹,新建styles.xml:
新建样式,名字为Transparent并且继承自AppTheme.Base:
<style name="Transparent" parent="AppTheme.Base"> <item name="android:colorPrimary">@color/colorPrimary</item> <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item> <item name="android:colorAccent">@color/colorAccent</item></style>
说明:values-v21文件夹中的内容是专门针对API21以上的版本所使用的配置文件,也就是说如果是API21之前的文件就是使用res/values中的styles.xml,否则使用values-v21文件夹下的styles.xml。
0 0
- Android--You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
- Android开发~you need to use a theme.appcompat theme (or descendant) with this activity
- 【Android】You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- Android Studio You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- Android错误之:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android Studio中报错 You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android问题一:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android异常-You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android Studio: You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android issue: You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- 非暴力沟通
- Python中的模块
- atomname
- socket客户端发送信息举例
- 面试题17 合并两个排序链表
- Android--You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
- Python包安装报错解决方法
- socket example
- Python下调用Linux的Shell命令
- 分布式锁的基本原理
- Spark源码学习(4)——Scheduler
- IOS开发多线程 - 多线程的简单介绍
- python安装numpy函数库
- 常见编程语言简介