use*_*569 17 android android-layout
我Theme.Black在我的应用程序中使用应用程序主题.在这个主题中,动作栏是灰色的.我如何改变动作栏的颜色?这是我的尝试:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="mytheme" parent="@android:style/Theme.Black" >
</style>
<style name="Widget.MyApp.ActionBar" parent="@android:style/Widget.ActionBar">
<item name="android:background">@android:color/black</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用.有任何想法吗?
use*_*831 23
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("COLOR"));
Run Code Online (Sandbox Code Playgroud)
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#C1000E</item>
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="AppTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.StatusBar.Title">
<item name="android:textColor">#E5ED0E</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我已经解决了使用它.
ActionBar actionBar;
actionBar = getActionBar();
ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#93E9FA"));
actionBar.setBackgroundDrawable(colorDrawable);
Run Code Online (Sandbox Code Playgroud)
也许这也可以帮助你。它来自网站:
\n\nhttp://nathanael.hevenet.com/android-dev-changing-the-title-bar-background/
\n\n\n\n\n首先,您需要为您的应用程序(或活动,取决于您的需要)声明一个自定义主题。类似于\xe2\x80\xa6
\n
<!-- Somewhere in AndroidManifest.xml -->\n<application ... android:theme="@style/ThemeSelector">\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n然后,为两种情况声明您的自定义主题,即带有和不带有 Holo 主题的 API 版本。对于旧主题,我们\xe2\x80\x99 将自定义 windowTitleBackgroundStyle 属性,对于新主题,我们将自定义 ActionBarStyle。
\n
<!-- res/values/styles.xml -->\n<?xml version="1.0" encoding="utf-8"?>\n<resources>\n\n <style name="ThemeSelector" parent="android:Theme.Light">\n <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>\n </style>\n\n <style name="WindowTitleBackground"> \n <item name="android:background">@color/title_background</item>\n </style>\n\n</resources>\n\n<!-- res/values-v11/styles.xml -->\n<?xml version="1.0" encoding="utf-8"?>\n<resources>\n\n <style name="ThemeSelector" parent="android:Theme.Holo.Light">\n <item name="android:actionBarStyle">@style/ActionBar</item>\n </style>\n\n <style name="ActionBar" parent="android:style/Widget.Holo.ActionBar"> \n <item name="android:background">@color/title_background</item>\n </style>\n\n</resources>\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n那\xe2\x80\x99就是它!
\n
| 归档时间: |
|
| 查看次数: |
95549 次 |
| 最近记录: |