2016-07-27 37 views
0

的权利我希望能够填补区域向右又不影响我的填充拇指填写进步拇指

enter image description here

我的进步XML左侧

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <size android:height="90dp"/> 
       <stroke android:width="2dp" android:color="#00ef3c"/> 
       <solid android:color="#00ffffff" /> 
      </shape> 
     </clip> 
    </item> 
    <item android:id="@+id/background"> 
     <clip> 
      <shape> 
       <size android:height="90dp"/> 
       <solid android:color="#bd767676" /> 
      </shape> 
     </clip> 
    </item> 
</layer-list> 

自定义搜索条风格

<style name="SeekbarCustom"> 
    <item name="android:indeterminate">false</item> 
    <item name="android:progressDrawable">@drawable/video_seek_bar_progress</item> 
    <item name="android:thumb">@drawable/video_seek_bar_thumb</item> 
    <item name="android:thumbOffset">8px</item> 
    <item name="android:focusable">true</item> 
</style> 

回答

0

所以我终于解决了它。不知道这是否是最好的解决方案。但它会做

我所做的是我让SecondaryProgress属性行为有填充。然后我把它的重力从右侧开始。然后我创建了一个监听器来改变它的进度。

听者

binding.fragmentPostVideoSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 
    @Override 
    public void onProgressChanged(SeekBar seekBar, int i, boolean b) { 
    int progress = seekBar.getProgress(); 
    seekBar.setSecondaryProgress(100 - progress); 
    } 
}); 

XML绘制

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <size android:height="90dp"/> 
       <stroke 
        android:width="2dp" 
        android:color="#00ef3c"/> 
       <solid android:color="#00ffffff"/> 
      </shape> 
     </clip> 
    </item> 
    <item android:id="@android:id/secondaryProgress"> 
     <clip android:gravity="right"> 
      <shape> 
       <size android:height="90dp"/> 
       <solid android:color="#b7797979"/> 
      </shape> 
     </clip> 
    </item> 
</layer-list>