gpt4 book ai didi

android - 如何在操作栏中变回狭窄并改变颜色

转载 作者:太空狗 更新时间:2023-10-29 16:02:38 24 4
gpt4 key购买 nike

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

这是我的 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>

最佳答案

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

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

关于android - 如何在操作栏中变回狭窄并改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26092799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com