且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安卓:下面动作条线改变颜色

更新时间:2023-02-05 18:42:26

您可以使用此code为实现你的目的。

background.xml

 < XML版本=1.0编码=UTF-8&GT?;
<层列表
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <项目>
        <形机器人:形状=矩形>
            [固体机器人:颜色=#FF0000/>
        < /形状>
    < /项目>
    <项目安卓底=5DP>
        <形机器人:形状=矩形>
            [固体机器人:颜色=#FFFFFF/>
        < /形状>
    < /项目>
< /层列表>
 

styles.xml

 <资源>
    <样式名称=AppTheme父=机器人:Theme.Holo>
        <项目名称=机器人:actionBarStyle> @风格/ AppTheme.ActionBar< /项目>
        <项目名称=机器人:背景>#FFFFFF< /项目>
        <项目名称=机器人:colorBackground>#FFFFFF< /项目>
    < /风格>
    <样式名称=AppTheme.ActionBar父=机器人:Widget.ActionBar>
        <项目名称=机器人:背景> @可绘制/背景< /项目>
    < /风格>
< /资源>
 

这些codeS都适合当你有没有喜欢的图像任何选项菜单显示有问题,如果你有选项菜单中,你必须自定义选项的菜单项的背景。

如果您有低于code选项菜单是适用的:

 <资源>
    <样式名称=AppTheme父=机器人:Theme.Holo.Light>
        <项目名称=机器人:actionBarStyle> @风格/ AppTheme.ActionBar< /项目>
        <项目名称=机器人:popupMenuStyle> @风格/ AppTheme.PopUpMenu< /项目>
    < /风格>
    <样式名称=AppTheme.ActionBar父=机器人:Widget.ActionBar>
        <项目名称=机器人:背景> @可绘制/背景< /项目>
    < /风格>
    <样式名称=AppTheme.PopUpMenu父=机器人:Widget.Holo.Light.ListPopupWindow>
        <项目名称=机器人:popupBackground> @可绘制/背景< /项目>
    < /风格>
< /资源>
 

I want to change the color of the orange line below the ActionBar.

I've tried a few things but nothing has helped so far.

The current theme on my Galaxy S2 is an orange theme. So changing the theme, also changes the line. But I don´t know how to get access to that line, in order to change the color.

You can use This code for achieving your purpose.

background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#ff0000" />
        </shape>
    </item>
    <item android:bottom="5dp">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </item>
</layer-list>

styles.xml

<resources>
    <style name="AppTheme" parent="android:Theme.Holo">
        <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
        <item name="android:background">#ffffff</item>
        <item name="android:colorBackground">#ffffff</item>
    </style>
    <style name="AppTheme.ActionBar" parent="android:Widget.ActionBar">
        <item name="android:background">@drawable/background</item>
    </style>
</resources>

These codes are suitable when you have not any options menu like image shows in question, if you have options menu you must customize your option menu items background.

If you have Option menu below code is suitable:

<resources>
    <style name="AppTheme" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
        <item name="android:popupMenuStyle">@style/AppTheme.PopUpMenu</item>
    </style>
    <style name="AppTheme.ActionBar" parent="android:Widget.ActionBar">
        <item name="android:background">@drawable/background</item>
    </style>
    <style name="AppTheme.PopUpMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
        <item name="android:popupBackground">@drawable/background</item>
    </style>
</resources>