Android的动作条的设置背景颜色颜色、背景、动作、Android

2023-09-12 02:22:05 作者:小姐烧着烟i

我经营着兼容性库V7。

我只想把我的动作条的颜色(为Android 2.1及以上 - 虽然我运行Android 4.4.2),以纯色

然而颜色不发生变化。它仍然是相同的。

我还试图建立一个固体可拉伸的颜色,但也不会改变。

最后,我测试过,如果我可以改变我的布局backgroudn,我可以 - 它必须是一些有关的动作条背景,我没有收到

下面是code:

 < XML版本=1.0编码=UTF-8&GT?;
<资源的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <样式名称=CustomActionBarTheme
           父=@风格/ Theme.AppCompat.Light.DarkActionBar>

        <! - 支持库的兼容性 - >
        <项目名称=actionBarStyle> @风格/ MyActionBar< /项目>
    < /风格>

    <样式名称=MyActionBar父=@风格/ Widget.AppCompat.ActionBar>

         <项目名称=机器人:背景>#0000FF< /项目>

    < /风格>
< /资源>
 

解决方案

我被解决了:

在正确安装的支持-V7-appcompat library.My错误。 转移的造型到RES /价值/ styles.xml文件的每个版本,即一个用于向后兼容性,一个用于值-V11。

我不知道为什么我不能得到我想要的范围内的themes.xml的结果。

怎么设置Android Studio代码字体及背景颜色

如果任何人有一个答案,我会感激不尽。

I am operating with the compatibility library v7.

I am just trying to set the color of my actionbar (for Android 2.1 and above - though I run Android 4.4.2) to a solid color.

However the color does not change. It remains the same.

I have also tried creating a solid drawable with the color but that also does not change.

Finally I tested if I could change the backgroudn of my layout and I could - it must be something about the actionbar background which I'm not getting.

Here is the code:

    <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="CustomActionBarTheme"
           parent="@style/Theme.AppCompat.Light.DarkActionBar">

        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">

         <item name="android:background">#0000ff</item>  

    </style>
</resources>

解决方案

I solved it by:

Properly installing the support-v7-appcompat library.My mistake. Shifting the styling to the res/values/styles.xml files for each version, i.e. one for backwards compatibility and one for values-v11.

I don't know why I couldnt get the result I wanted within themes.xml.

If anyone has an answer I'd be grateful