前言

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

  1. <SeekBar
  2.   android:id="@+id/play_sb_process"
  3.   android:layout_width="754dp"
  4.   android:layout_height="40dp"
  5.   android:duplicateParentState="true"
  6.   android:progressDrawable="@drawable/seek_bar_img"
  7.   android:thumb="@color/transparent" />
复制

seek_bar_img的xml如下

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  3.   <item
  4.       android:id="@android:id/background"
  5.       android:drawable="@drawable/seek_bar_bg_n"/>
  6.   <item
  7.       android:id="@android:id/secondaryProgress"
  8.       android:drawable="@drawable/seek_bar_bg_n"/>
  9.   <item
  10.       android:id="@android:id/progress"
  11.       android:drawable="@drawable/seek_bar_bg_p"/>
  12. </layer-list>
复制

进度条progress上存在一个黑点

正文

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

分析

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

  1. public void setThumb(Drawable thumb) {
  2.   final boolean needUpdate;
  3.   if (mThumb != null && thumb != mThumb) {
  4.       mThumb.setCallback(null);
  5.       needUpdate = true;
  6.   } else {
  7.       needUpdate = false;
  8.   }
  9.   if (thumb != null) {
  10.       thumb.setCallback(this);
  11.       if (canResolveLayoutDirection()) {
  12.           thumb.setLayoutDirection(getLayoutDirection());
  13.       }
  14.       mThumbOffset = thumb.getIntrinsicWidth() / 2;
  15.       if (needUpdate &&
  16.               (thumb.getIntrinsicWidth() != mThumb.getIntrinsicWidth()
  17.                   || thumb.getIntrinsicHeight() != mThumb.getIntrinsicHeight())) {
  18.           requestLayout();
  19.       }
  20.   }
  21.   mThumb = thumb;
  22.   applyThumbTint();
  23.   invalidate();
  24.   if (needUpdate) {
  25.       updateThumbAndTrackPos(getWidth(), getHeight());
  26.       if (thumb != null && thumb.isStateful()) {
  27.           int[] state = getDrawableState();
  28.           thumb.setState(state);
  29.       }
  30.   }
  31. }
复制

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

参考文章

相关文章

暂无评论

none
暂无评论...