Seekbar Setprogress Trashes Secondary Progress
I have primary and secondary progress growing in the same time, secondary progress grows faster than primary. Everytime I update the primary progress, the secondary one is lost (li
Solution 1:
This has been fixed for the next Android release, but the best workaround for now would probably be to copy scrubber_progress_horizontal_material.xml
and its 9-patch PNGs from the SDK resources (<sdk-root>/platforms/android-21/data/res/...
), then to rearrange the tags so that <layer-list>
is at the root.
Here is what the revised XML should look like:
drawable-v21/scrubber_progress_horizontal_material_fixed.xml
<layer-listxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:id="@android:id/background"><nine-patchandroid:src="@drawable/scrubber_track_mtrl_alpha"android:tint="?android:attr/colorControlNormal" /></item><itemandroid:id="@android:id/secondaryProgress"><scaleandroid:scaleWidth="100%"><selector><itemandroid:state_enabled="false"><colorandroid:color="@android:color/transparent" /></item><item><nine-patchandroid:src="@drawable/scrubber_primary_mtrl_alpha"android:tint="?android:attr/colorControlNormal" /></item></selector></scale></item><itemandroid:id="@android:id/progress"><scaleandroid:scaleWidth="100%"><selector><itemandroid:state_enabled="false"><colorandroid:color="@android:color/transparent" /></item><item><nine-patchandroid:src="@drawable/scrubber_primary_mtrl_alpha"android:tint="?android:attr/colorControlActivated" /></item></selector></scale></item></layer-list>
And then the appropriate changes in values-v21/styles.xml
and/or your layout XML so that you use this background by default on API 21+. I can include examples for those if you need them.
Post a Comment for "Seekbar Setprogress Trashes Secondary Progress"