gpt4 book ai didi

android - 设置SeekBar的进度颜色为透明

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:45:06 25 4
gpt4 key购买 nike

这是我想要完成的图片,其中没有进度颜色(透明),带有纯灰色背景栏:

seekbar

我试过了

android:progressTint="#00000000"

但这会将整个进度条(进度条和后退条)设置为透明。

我也试过:

android:progressDrawable="@drawable/customseekbar"

其中 customseekbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@android:id/background"
android:drawable="@drawable/seekbar_background" />

<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seekbar_background" />
</item>

和 seekbar_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#FF555555" />
</shape>

但后来我变得又胖又丑:

notwhatiwant

我在这里做错了什么?谢谢

最佳答案

如何在 Android 中设置 Seekbar 的样式

给你,你需要做以下事情

第 1 步:

在drawable中,放入“progress_bg.png”(见附件)

第 2 步:

在drawable中,创建“myprogessbar_style.xml”,并插入以下内容

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@android:id/background"
android:drawable="@drawable/progress_bg" />
<item
android:id="@android:id/secondaryProgress"
>
<scale
android:drawable="@drawable/progress_bg"
android:scaleWidth="100%"/>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/progress_bg"/>

</layer-list>

第 3 步:

你的搜索栏

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:indeterminate="false"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:progressDrawable="@drawable/myprogessbar_style"/>

结果

enter image description here

附件

enter image description here

附言是的,这不是透明度而是预期的结果

关于android - 设置SeekBar的进度颜色为透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33380976/

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