【问题标题】:how to change back narrow and change color in actionbar如何在操作栏中变窄并更改颜色
【发布时间】:2014-09-29 04:58:51
【问题描述】:

我想更改操作栏中的颜色并更改后缩图标。当我只是改变背部变窄时它的工作,但是当我在操作栏中设置颜色时,图标消失了。我想将操作栏的颜色更改为蓝色。

这是我在 xml 中的代码:

<?xml version="1.0" encoding="utf-8"?>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.


-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.

    -->
</style>

<style name="AppBaseAlternativeTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="AppAlternativeTheme" parent="AppBaseAlternativeTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="CustomUpIndicatorTheme" parent="AppAlternativeTheme">
    <item name="android:homeAsUpIndicator">@drawable/ic_up_indicator</item>
</style>

    <!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:background">@color/action_bar</item>
</style>

【问题讨论】:

    标签: android android-actionbar styling


    【解决方案1】:

    您可以在 Activity 中使用以下代码来执行此操作。

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_actionbar_screen_back);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.actionbar_background_color)));
    

    【讨论】:

      【解决方案2】:

      试试看-

      ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ffffffff"));
      getSupportActionBar().setBackgroundDrawable(colorDrawable);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多