Seekbar进度条有黑点问题分析

Android2023年6月25日 am9:37发布1年前 (2023)更新 3XCN.COM站长
1 0 0
广告也精彩
目录

前言

同样的代码,在不同设备上可能存在不同的表现。目前测试在MTK的平台上发现,使用如下代码:

<SeekBar
    android:id="@+id/play_sb_process"
    android:layout_width="754dp"
    android:layout_height="40dp"
    android:duplicateParentState="true"
    android:progressDrawable="@drawable/seek_bar_img"
    android:thumb="@color/transparent" />

seek_bar_img的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/seek_bar_bg_n"/>
    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/seek_bar_bg_n"/>
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/seek_bar_bg_p"/>
</layer-list>

进度条progress上存在一个黑点

正文

一开始以为是UI的切图问题,然后找了其他正常的UI放上去,还是存在。

分析

先分析前,需要看一下setThumb源码(初始化也是获取thumb并通过这个方法设置的)。

public void setThumb(Drawable thumb) {
    final boolean needUpdate;
    if (mThumb != null && thumb != mThumb) {
        mThumb.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (thumb != null) {
        thumb.setCallback(this);
        if (canResolveLayoutDirection()) {
            thumb.setLayoutDirection(getLayoutDirection());
        }
        mThumbOffset = thumb.getIntrinsicWidth() / 2;
        if (needUpdate &&
                (thumb.getIntrinsicWidth() != mThumb.getIntrinsicWidth()
                    || thumb.getIntrinsicHeight() != mThumb.getIntrinsicHeight())) {
            requestLayout();
        }
    }

    mThumb = thumb;

    applyThumbTint();
    invalidate();

    if (needUpdate) {
        updateThumbAndTrackPos(getWidth(), getHeight());
        if (thumb != null && thumb.isStateful()) {
            int[] state = getDrawableState();
            thumb.setState(state);
        }
    }
}

隐藏内容!
付费阅读后才能查看!
1
多个隐藏块只需支付一次

参考文章

 历史上的今天

版权声明 1、 本站名称: 91易搜
2、 本站网址: 91es.com3xcn.com
3、 本站文章: 部分来源于网络,仅供站长学习和参考,若侵权请留言
广告也精彩

相关文章

广告也精彩

暂无评论

评论审核已启用。您的评论可能需要一段时间后才能被显示。

暂无评论...

网站升级中

公告

近期网站升级中,可能存在一些bug。欢迎反馈 https://www.91es.com/we.html

本站域名

本站域名 : 91es.com3xcn.com。本站邮箱 : 站长邮箱 i@oorr.cn,通知邮箱we@oorr.cn ,如有更新,请看公告 。