【问题标题】:Set gradient for Android ActionBar为 Android ActionBar 设置渐变
【发布时间】:2012-09-04 09:08:20
【问题描述】:

我在我的应用程序中使用了一个 ActionBarSherlock 库。我还需要自定义 ActionBar,所以我添加了一个带有 background 参数集的自定义主题,如下所示:

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">

<item name="background">@drawable/action_bar_bg</item>

<item name="android:background">@drawable/action_bar_bg</item>

</style>

action_bar_bg drawable 只是平铺正方形的位图:

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

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:src="@drawable/bg_img_actionbar"
    android:tileMode="repeat" />

接下来我要做的是为整个ActionBar设置一个线性渐变,这样它就会覆盖这个背景。而且我不知道这是否可能以及如何做到这一点。 任何帮助将不胜感激。

【问题讨论】:

    标签: android android-actionbar actionbarsherlock xml-drawable


    【解决方案1】:

    【讨论】:

    • 是的,但据我所知,它允许我设置图像的颜色,而不是平铺背景。
    • 我不懂你。平铺还是渐变?您要同时使用两者吗?
    • 是的。目前我有一个带有平铺背景的 ActionBar,我还想在它上面添加一个线性渐变。
    • Combinando ShapeDrawable y LayerList creo que podría conseguirlo。 developer.android.com/guide/topics/resources/…
    • 只是为了翻译 JMPergars 评论:将 shape drawable 与 LayerList 结合起来应该可以工作:developer.android.com/guide/topics/resources/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多