删除android进度条中的进度条背景 [英] Remove progress bar background in android progress bar

查看:95
本文介绍了删除android进度条中的进度条背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何去除灰色背景,只在进度条中显示蓝色进度条.

How do I remove the grey background and only display the blue progress strip in the progress bar.

推荐答案

我已经回答了一个有类似要求的问题:

I have already answered a question with a similar requirement:

结果:

要删除它,只需按 id 搜索背景并尝试隐藏它是行不通的.要删除背景,我必须创建与系统版本相同的 drawble 并删除背景项.

To remove it, simply searching for the background by id and trying to hide it doesn't work. To remove the background, I had to create identical drawble of the system version and remove the background item.

TL;DR:创建文件 progress_horizo​​ntal_holo_no_background_light.xml 并粘贴此可绘制对象:

TL;DR: Create file progress_horizontal_holo_no_background_light.xml and paste this drawable:

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

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

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

</layer-list>

将适当的 .png drawable 从 sdk/platforms/android-xx/data/res/drawable-xxx/ 复制到您的项目中,然后在代码中添加:

Copy appropriate .png drawables from sdk/platforms/android-xx/data/res/drawable-xxx/ to your project and then in the code you can add:

progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_horizontal_holo_no_background_light));

或在包含 ProgressBar

android:progressDrawable="@drawable/progress_horizontal_holo_no_background_light"

这篇关于删除android进度条中的进度条背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆