android studio androidtheme editor,无法在Android Studio中更改主题(Failure to change Theme in Android Studio)...

无法在Android Studio中更改主题(Failure to change Theme in Android Studio)

我想将主题更改为Theme.Holo,但是当我运行应用程序时它崩溃了。 我只在Manifest.xml中进行了如下所示的更改,到目前为止还没有显示错误消息。

原版的:

更改:

这是logcat:

java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)。

logcat消息似乎告诉我我只能使用Theme.AppCompat,我认为这个主题来自支持库appcompat v7:22。

我试图在Android开发者网站上搜索下面的链接,但似乎上面的设置与他们的建议没有区别

我可以知道为什么我只能使用支持库v7:22中的主题吗? 有什么我想错过的吗?

I want to change the Theme to Theme.Holo, but it was crashed when I run the apps. I only made change in Manifest.xml as below, and so far there are no error message shown.

Original:

Changed:

Here is the logcat:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

logcat message seem to tell me I can only use the Theme.AppCompat, and I think this theme is coming from supporting library appcompat v7:22.

I have tried to search around the link as below from Android developer site, but seem the setting above has no difference with their suggestion

May I know why I can only use the Theme from the supporting library v7:22? Is there something I missed to change?

原文:https://stackoverflow.com/questions/30284946

更新时间:2020-01-04 09:21

最满意答案

是的还有更多。 您的活动是扩展AppCompatActivity或ActionBarActivity ,并且需要Theme.AppCompat主题或任何后代。 您只需要从支持库v4将其更改为Activity或FragmentActivity 。

Yes there is something more. Your activity is extending AppCompatActivity or ActionBarActivity and that needs a Theme.AppCompat theme or any descendant. You just need to change that to Activity or FragmentActivity from support library v4.

2015-05-17

相关问答

您可能会尝试如下更改设置>颜色和字体>方案 尝试编辑设置>外观>主题 You might be tried to change Settings > Colors&Fonts > Scheme like below Try to edit Settings > Appearances > Theme

File->Settings->Editor->Colors & Fonts->在方案名称中选择达库拉并申请看到一个真棒黑暗的背景主题编辑器 File->Settings->Editor->Colors & Fonts-> In scheme name select Darcula and apply to see a awesome dark background theme editor Android Studio 3.1.2 File->Settings->Editor->Color Sc

...

我想你正在尝试'在Android Studio中进行设计预览'。 在'设计'标签中(你现在在哪里),你可以看到它在不同的手机和Android SDK版本中的样子。 如果您想永久更改App主题, 转到res/values/styles.xml并定制您自己的主题-ex)'AppTheme' 在AndroidManifest.xml ,你可以通过像这样的命名空间“theme”来设置它android:theme="@style/AppTheme" I think you're trying 'Design

...

将您的switch更改为: switch (cTheme)

{

case BLACK:

int myTheme = R.style.Default

activity.setTheme(myTheme);

//Save your activity theme color

saveTheme(myTheme);

break;

case YELLOW:

int myTheme =

...

您正在使用此主题进行所有活动 android:theme="@style/CustomActionBarTheme"

这是一个全息主题。 尝试改为 android:theme="@style/AppTheme"

对于特定的活动 You are using this theme for all your activity android:theme="@style/CustomActionBarTheme"

which is a holo theme. Try changing into

...

是的还有更多。 您的活动是扩展AppCompatActivity或ActionBarActivity ,并且需要Theme.AppCompat主题或任何后代。 您只需要从支持库v4将其更改为Activity或FragmentActivity 。 Yes there is something more. Your activity is extending AppCompatActivity or ActionBarActivity and that needs a Theme.AppCompat

...

嘿,你能展示你所说的活动代码吗? 特别是宣言。 我以前遇到过此错误,可能与您未在活动声明中扩展(扩展)正确的操作栏有关。 例如 : extends ActionBarActivity

Hey can you show your code for said activity? Especially the declaration. I've had this error before and it might have to do witht the fact that you aren't ex

...

首先,当您更改名称时,请使用Android studio中的重构选项(右键单击包并单击重命名)。 那么你仍然会看到旧包的原因是Android Studio没有检测到任何代码更改,只是给你已经构建的包。 您可以通过project clean来更改此设置。 如果您有任何问题,请发表评论 First of all, when you change the name do it using the refactoring option in Android studio (right click on t

...

我有同样的问题: 由于您的项目似乎是使用默认配置的新项目,并且您已经拥有:

false

true

并且: android:theme="@style/AppTheme.NoActionBar">

在您的Manifest ,它似乎

...

您想要在外观和行为下单击外观设置文件>设置.... 您可以在此处更改主题。 You want to got to settings File>Settings... under Appearance & Behavior click on Appearance. You can change the Theme here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值