Move layer-list to be top-level element in seek bar progress

There is a bug in <scale>, but this works around it for now. Removes
the previous fix, which broke the initial state due to the level not
propagating when the current drawable was swapped out.

Bug: 19269656
Change-Id: Ibe586ef4ea326a7ce7516ca42a369c5386c24359
This commit is contained in:
Alan Viverette
2015-02-04 17:15:01 -08:00
parent 81c8018031
commit bac8e12ebd
2 changed files with 30 additions and 24 deletions

View File

@@ -1241,7 +1241,7 @@ public class ProgressBar extends View {
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
boolean callBackToApp) { boolean callBackToApp) {
float scale = mMax > 0 ? (float) progress / (float) mMax : 0; float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
final Drawable d = mCurrentDrawable.getCurrent(); final Drawable d = mCurrentDrawable;
if (d != null) { if (d != null) {
Drawable progressDrawable = null; Drawable progressDrawable = null;

View File

@@ -14,29 +14,35 @@
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<nine-patch android:src="@drawable/scrubber_track_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item>
<layer-list>
<item android:id="@id/background"> <item android:id="@id/background">
<nine-patch android:src="@drawable/scrubber_track_mtrl_alpha" <nine-patch android:src="@drawable/scrubber_track_mtrl_alpha"
android:tint="?attr/colorControlNormal" /> android:tint="?attr/colorControlNormal" />
</item> </item>
<item android:id="@id/secondaryProgress"> <item android:id="@id/secondaryProgress">
<scale android:scaleWidth="100%"> <scale android:scaleWidth="100%">
<selector>
<item android:state_enabled="false">
<color android:color="@color/transparent" />
</item>
<item>
<nine-patch android:src="@drawable/scrubber_primary_mtrl_alpha" <nine-patch android:src="@drawable/scrubber_primary_mtrl_alpha"
android:tint="?attr/colorControlNormal" /> android:tint="?attr/colorControlNormal" />
</item>
</selector>
</scale> </scale>
</item> </item>
<item android:id="@id/progress"> <item android:id="@id/progress">
<scale android:scaleWidth="100%"> <scale android:scaleWidth="100%">
<selector>
<item android:state_enabled="false">
<color android:color="@color/transparent" />
</item>
<item>
<nine-patch android:src="@drawable/scrubber_primary_mtrl_alpha" <nine-patch android:src="@drawable/scrubber_primary_mtrl_alpha"
android:tint="?attr/colorControlActivated" /> android:tint="?attr/colorControlActivated" />
</item>
</selector>
</scale> </scale>
</item> </item>
</layer-list> </layer-list>
</item>
</selector>