Allow color state list for vector drawable fill and stroke

Removes unnecessary invalidateSelf() from VD.onStateChange(). This is
handled by the view hosting the drawable.

Bug: 22984152
Change-Id: Idf11a0ffef392cb1d8452aa3f5f836b35027a756
This commit is contained in:
Alan Viverette
2015-09-22 15:03:50 -04:00
parent 31cb4bb41f
commit 50c29cd92f
3 changed files with 175 additions and 36 deletions

View File

@@ -20,11 +20,15 @@
android:viewportWidth="480" >
<group>
<path
android:name="box0"
android:pathData="m0,0l480,0l0,480l-480,0l0-480z"
android:fillColor="@android:color/white" />
<path
android:name="box1"
android:pathData="m20,200l100,90l180-180l-35-35l-145,145l-60-60l-40,40z"
android:fillColor="?android:attr/colorControlActivated"
android:strokeColor="?android:attr/colorControlActivated"
android:fillColor="?android:attr/colorControlNormal"
android:strokeColor="?android:attr/colorControlNormal"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</group>

View File

@@ -18,7 +18,12 @@ import android.graphics.drawable.VectorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.GridLayout;
@SuppressWarnings({"UnusedDeclaration"})
@@ -55,6 +60,23 @@ public class VectorDrawable01 extends Activity {
container.setBackgroundColor(0xFF888888);
final Button []bArray = new Button[icon.length];
CheckBox toggle = new CheckBox(this);
toggle.setText("Toggle");
toggle.setChecked(true);
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ViewGroup vg = (ViewGroup) buttonView.getParent();
for (int i = 0, count = vg.getChildCount(); i < count; i++) {
View child = vg.getChildAt(i);
if (child != buttonView) {
child.setEnabled(isChecked);
}
}
}
});
container.addView(toggle);
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
bArray[i] = button;