spc*_*ial 2 java xml android android-studio
我在以下Preview窗口中收到以下错误Android Studio:
渲染问题缺少样式.是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用.无法在当前主题中找到"?attr/actionBarPopupTheme".(4个类似错误未显示)
我创建了一个自定义样式/主题.这是关于styles.xml:
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="actionBarTheme">@style/MyActionBarTheme</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">@color/white</item>
<item name="titleTextStyle">@style/MyActionBar.ActionBar.TitleTextStyle</item>
<item name="background">@color/bg_common</item>
</style>
<style name="MyActionBarTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="actionMenuTextColor">@color/title</item>
<item name="colorControlNormal">@color/title</item>
</style>
<style name="MyActionBar.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/title</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我的布局文件标题如下所示:
<android.support.v4.widget.DrawerLayout
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">
...
Run Code Online (Sandbox Code Playgroud)
在我的清单文件中,我在应用程序标记中添加了:
android:theme="@style/CustomActionBarTheme"
Run Code Online (Sandbox Code Playgroud)
为什么我会收到错误?我也在CustomActionBarTheme预览窗口中选择了主题.我错过了什么吗?在此先感谢您的任何建议!
| 归档时间: |
|
| 查看次数: |
3329 次 |
| 最近记录: |