android studio 关闭rendering problems,Android Studio Rendering Problems - Missing styles?

在Android Studio中遇到布局预览错误,提示缺失样式。尝试切换到较低的API级别,如从23降到22,可以解决由于最新SDK导致的预览问题。此外,检查布局文件中的主题设置和manifest文件中应用的主题是否一致,确保CustomActionBarTheme已被正确引用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题

I get following error in the Preview window of Android Studio:

Rendering Problems Missing styles. Is the correct theme chosen for

this layout? Use the Theme combo box above the layout to choose a

different layout, or fix the theme style references. Failed to find

'?attr/actionBarPopupTheme' in current theme. (4 similar errors not

shown)

I have created a custom style/theme. This is the regarding styles.xml:

@style/MyActionBar

@style/MyActionBar

@style/MyActionBarTheme

@color/white

@style/MyActionBar.ActionBar.TitleTextStyle

@color/bg_common

@color/title

@color/title

@color/title

My layout file header looks like this:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

style="@style/CustomActionBarTheme"

android:id="@+id/drawer_layout"

android:background="@color/bg_common_2"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

...

And in my manifest file I have added in the application tag:

android:theme="@style/CustomActionBarTheme"

Why do I get the error? I also choosed CustomActionBarTheme in my Preview windows as Theme. Am I missing something? Thanks for any advice in advance!

回答1:

Android Studio uses the latest SDK installed to preview layout files. This can lead to preview errors due to missing styles - switching to an older API level (e.g. from 23 to 22) can fix this.

回答2:

Another way is to change layout theme (near SDK preview version button)

Works fine

来源:https://stackoverflow.com/questions/34076213/android-studio-rendering-problems-missing-styles

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值