gpt4 book ai didi

android - Toolbar with Gradient Background 设置标题背景透明

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:23 26 4
gpt4 key购买 nike

我定义了一个 Gradient Drawable:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<gradient
android:endColor="#2F3F59"
android:startColor="#4078A7"
android:type="linear"
android:angle="90" />

</shape>

然后我将它设置在我的工具栏上:

<style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/textcolorsecundary</item>
<item name="actionMenuTextColor">@color/textcolorsecundary</item>
<item name="android:textColorSecondary">@color/textcolorsecundary</item>
<item name="android:background">@drawable/custom_background_blue</item>
</style>

这是工作! 但是:

enter image description here

标题就是这样。它得到相同的梯度。这看起来真的很难看,所以我必须改变它。如何将信息文本的背景设置为透明?

最佳答案

您还可以通过将工具栏的背景设置为您的可绘制对象来解决此问题。

mToolbar().setDrawable(R.drawable.your_gradient)

关于android - Toolbar with Gradient Background 设置标题背景透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28817109/

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