2017-08-29 65 views
0

我有一个seekbar,其高度为16dpSeekbar progressdrawable无法在Android M下正常工作

minHeight="16dp" 
maxHeight="16dp" 

现在我必须使用自定义进度drawable。

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/background"> 
    <shape android:shape="rectangle"> 
     <solid android:color="xxx"/> 
     <corners android:radius="6dp"/> 
    </shape> 
</item> 

<item 
    android:id="@android:id/secondaryProgress" 
    android:bottom="4dp" 
    android:left="4dp" 
    android:right="4dp" 
    android:top="4dp"> 
    <clip> 
     <shape android:shape="rectangle"> 
      <solid android:color="xxx"/> 
      <corners android:radius="4dp"/> 
     </shape> 
    </clip> 
</item> 

<item 
    android:id="@android:id/progress" 
    android:bottom="4dp" 
    android:left="4dp" 
    android:right="4dp" 
    android:top="4dp"> 
    <clip> 
     <shape android:shape="rectangle"> 
      <solid android:color="xxx"/> 
      <corners 
       android:radius="4dp"/> 
     </shape> 
    </clip> 
</item> 

正如你看到的,我用lefttoprightbottom插入progresssecondaryProgress

它运作良好以上版本的Android M,但是下面的Android M时,porgress和secondaryProgress其他字background项目是由progresssecondaryProgress覆盖填充background但我想进度和secondaryProgress比背景项目小。

回答

0

有一个解决方案:

LayerDrawable drawable = (LayerDrawable) mSeekBar.getProgressDrawable(); 
// secondaryProgress 
drawable.setLayerInset(1, padding, padding, padding, padding); 
// progress 
drawable.setLayerInset(2, padding, padding, padding, padding); 

任何人都可以解释为什么它是无用的设置leftrighttop在XML bottom低于API 23?

相关问题