下面列出了android.util.TypedValue#TYPE_FLOAT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
Description parseValue(TypedValue value) {
Description d = new Description();
if (value == null) {
d.type = ABSOLUTE;
d.value = 0;
} else {
if (value.type == TypedValue.TYPE_FRACTION) {
d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
d.value = TypedValue.complexToFloat(value.data);
return d;
} else if (value.type == TypedValue.TYPE_FLOAT) {
d.type = ABSOLUTE;
d.value = value.getFloat();
return d;
} else if (value.type >= TypedValue.TYPE_FIRST_INT &&
value.type <= TypedValue.TYPE_LAST_INT) {
d.type = ABSOLUTE;
d.value = value.data;
return d;
}
}
d.type = ABSOLUTE;
d.value = 0.0f;
return d;
}
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static float getFloat(Context context, @DimenRes int id) {
TypedValue value = VALUE;
context.getResources().getValue(id, value, true);
if (value.type == TypedValue.TYPE_FLOAT) {
return value.getFloat();
}
throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id)
+ " type #0x" + Integer.toHexString(value.type) + " is not valid");
}
private static String getAttributeValue(XmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
if (type == 0x07) {
return String.format("@%s%08X", getPackage(data), data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
public float getAttributeFloatValue(int index, float defaultValue) {
int offset = getAttributeOffset(index);
int valueType = m_attributes[offset + ATTRIBUTE_IX_VALUE_TYPE];
if (valueType == TypedValue.TYPE_FLOAT) {
int valueData = m_attributes[offset + ATTRIBUTE_IX_VALUE_DATA];
return Float.intBitsToFloat(valueData);
}
return defaultValue;
}
/**
* Retrieve a floating-point value for a particular resource ID.
*
* @param id The desired resource identifier, as generated by the aapt
* tool. This integer encodes the package, type, and resource
* entry. The value 0 is an invalid identifier.
*
* @return Returns the floating-point value contained in the resource.
*
* @throws NotFoundException Throws NotFoundException if the given ID does
* not exist or is not a floating-point value.
* @hide Pending API council approval.
*/
public float getFloat(int id) {
final TypedValue value = obtainTempTypedValue();
try {
mResourcesImpl.getValue(id, value, true);
if (value.type == TypedValue.TYPE_FLOAT) {
return value.getFloat();
}
throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id)
+ " type #0x" + Integer.toHexString(value.type) + " is not valid");
} finally {
releaseTempTypedValue(value);
}
}
public float getAttributeFloatValue(int idx, float defaultValue) {
int t = nativeGetAttributeDataType(mParseState, idx);
// Note: don't attempt to convert any other types, because
// we want to count on aapt doing the conversion for us.
if (t == TypedValue.TYPE_FLOAT) {
return Float.intBitsToFloat(
nativeGetAttributeData(mParseState, idx));
}
throw new RuntimeException("not a float!");
}
private Description parseValue(TypedValue value) {
Description d = new Description();
if (value == null) {
d.type = ABSOLUTE;
d.value = 0;
} else {
if (value.type == TypedValue.TYPE_FRACTION) {
d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
d.value = TypedValue.complexToFloat(value.data);
return d;
} else if (value.type == TypedValue.TYPE_FLOAT) {
d.type = ABSOLUTE;
d.value = value.getFloat();
return d;
} else if (value.type >= TypedValue.TYPE_FIRST_INT &&
value.type <= TypedValue.TYPE_LAST_INT) {
d.type = ABSOLUTE;
d.value = value.data;
return d;
}
}
d.type = ABSOLUTE;
d.value = 0.0f;
return d;
}
private static String getAttributeValue(AXmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data == 0 ? "false" : "true";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) +
DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) +
FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
@Test(expected = IllegalArgumentException.class)
public void testGetDrawableWhenTypeIsSomethingElse() {
TypedArray typedArray = mock(TypedArray.class);
TypedValue typedValue = spy(new TypedValue());
typedValue.type = TypedValue.TYPE_FLOAT;
when(typedArray.peekValue(anyInt())).thenReturn(typedValue);
ThemeUtil.getDrawable(getApplicationContext(), typedArray, anyInt());
}
private static String getAttributeValue(XmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data))
+ DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data))
+ FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT
&& type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT
&& type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
public float getAttributeFloatValue(int index,float defaultValue) {
int offset=getAttributeOffset(index);
int valueType=m_attributes[offset+ATTRIBUTE_IX_VALUE_TYPE];
if (valueType==TypedValue.TYPE_FLOAT) {
int valueData=m_attributes[offset+ATTRIBUTE_IX_VALUE_DATA];
return Float.intBitsToFloat(valueData);
}
return defaultValue;
}
public float getAttributeFloatValue(int index, float defaultValue) {
int offset = getAttributeOffset(index);
int valueType = m_attributes[offset + ATTRIBUTE_IX_VALUE_TYPE];
if (valueType == TypedValue.TYPE_FLOAT) {
int valueData = m_attributes[offset + ATTRIBUTE_IX_VALUE_DATA];
return Float.intBitsToFloat(valueData);
}
return defaultValue;
}
private static String getAttributeValue(AXmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) +
DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) +
FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
public float getAttributeFloatValue(int index,float defaultValue) {
int offset=getAttributeOffset(index);
int valueType=m_attributes[offset+ATTRIBUTE_IX_VALUE_TYPE];
if (valueType==TypedValue.TYPE_FLOAT) {
int valueData=m_attributes[offset+ATTRIBUTE_IX_VALUE_DATA];
return Float.intBitsToFloat(valueData);
}
return defaultValue;
}
Description parseValue(TypedValue value) {
Description d = new Description();
if (value == null) {
d.type = ABSOLUTE;
d.value = 0;
} else {
if (value.type == TypedValue.TYPE_FRACTION) {
d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
d.value = TypedValue.complexToFloat(value.data);
return d;
} else if (value.type == TypedValue.TYPE_FLOAT) {
d.type = ABSOLUTE;
d.value = value.getFloat();
return d;
} else if (value.type >= TypedValue.TYPE_FIRST_INT &&
value.type <= TypedValue.TYPE_LAST_INT) {
d.type = ABSOLUTE;
d.value = value.data;
return d;
}
}
d.type = ABSOLUTE;
d.value = 0.0f;
return d;
}
private static String getAttributeValue(XmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
@SuppressWarnings("unchecked")
private T extractNumericValueFromAttributes(TypedArray a, int attribute, int defaultValue) {
TypedValue tv = a.peekValue(attribute);
if (tv == null) {
return (T) Integer.valueOf(defaultValue);
}
int type = tv.type;
if (type == TypedValue.TYPE_FLOAT) {
return (T) Float.valueOf(a.getFloat(attribute, defaultValue));
} else {
return (T) Integer.valueOf(a.getInteger(attribute, defaultValue));
}
}
/**
* Parse a name/value pair out of an XML tag holding that data. The
* AttributeSet must be holding the data defined by
* {@link android.R.styleable#Extra}. The following value types are supported:
* <ul>
* <li> {@link TypedValue#TYPE_STRING}:
* {@link Bundle#putCharSequence Bundle.putCharSequence()}
* <li> {@link TypedValue#TYPE_INT_BOOLEAN}:
* {@link Bundle#putCharSequence Bundle.putBoolean()}
* <li> {@link TypedValue#TYPE_FIRST_INT}-{@link TypedValue#TYPE_LAST_INT}:
* {@link Bundle#putCharSequence Bundle.putBoolean()}
* <li> {@link TypedValue#TYPE_FLOAT}:
* {@link Bundle#putCharSequence Bundle.putFloat()}
* </ul>
*
* @param tagName The name of the tag these attributes come from; this is
* only used for reporting error messages.
* @param attrs The attributes from which to retrieve the name/value pair.
* @param outBundle The Bundle in which to place the parsed value.
* @throws XmlPullParserException If the attributes are not valid.
*/
public void parseBundleExtra(String tagName, AttributeSet attrs,
Bundle outBundle) throws XmlPullParserException {
TypedArray sa = obtainAttributes(attrs,
com.android.internal.R.styleable.Extra);
String name = sa.getString(
com.android.internal.R.styleable.Extra_name);
if (name == null) {
sa.recycle();
throw new XmlPullParserException("<" + tagName
+ "> requires an android:name attribute at "
+ attrs.getPositionDescription());
}
TypedValue v = sa.peekValue(
com.android.internal.R.styleable.Extra_value);
if (v != null) {
if (v.type == TypedValue.TYPE_STRING) {
CharSequence cs = v.coerceToString();
outBundle.putCharSequence(name, cs);
} else if (v.type == TypedValue.TYPE_INT_BOOLEAN) {
outBundle.putBoolean(name, v.data != 0);
} else if (v.type >= TypedValue.TYPE_FIRST_INT
&& v.type <= TypedValue.TYPE_LAST_INT) {
outBundle.putInt(name, v.data);
} else if (v.type == TypedValue.TYPE_FLOAT) {
outBundle.putFloat(name, v.getFloat());
} else {
sa.recycle();
throw new XmlPullParserException("<" + tagName
+ "> only supports string, integer, float, color, and boolean at "
+ attrs.getPositionDescription());
}
} else {
sa.recycle();
throw new XmlPullParserException("<" + tagName
+ "> requires an android:value or android:resource attribute at "
+ attrs.getPositionDescription());
}
sa.recycle();
}
void initialize() {
Context context = getContext();
final Resources res = getResources();
final TypedArray a = context.obtainStyledAttributes(R.styleable.ButtonLayout);
if (SUtils.isApi_17_OrHigher()) {
setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
}
setOrientation(HORIZONTAL);
setGravity(Gravity.BOTTOM);
setPadding(res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_start),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_top),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_end),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_bottom));
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.decision_button_layout, this, true);
Button bPositive = (Button) findViewById(R.id.buttonPositive);
Button bNegative = (Button) findViewById(R.id.buttonNegative);
ImageView ivPositive = (ImageView) findViewById(R.id.imageViewPositive);
ImageView ivNegative = (ImageView) findViewById(R.id.imageViewNegative);
try {
// obtain float value held by android.R.attr.disabledAlpha
TypedValue typedValueDisabledAlpha = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
typedValueDisabledAlpha, true);
// defaults to 0.5 ~ 122/255
mDisabledAlpha = typedValueDisabledAlpha.type == TypedValue.TYPE_FLOAT ?
(int) (typedValueDisabledAlpha.getFloat() * 255)
: 122;
// buttons or icons?
int presentation = a.getInt(R.styleable.ButtonLayout_spPresentation, 0);
int bgColor = a.getColor(R.styleable.ButtonLayout_spButtonBgColor,
SUtils.COLOR_BUTTON_NORMAL);
int pressedBgColor = a.getColor(R.styleable.ButtonLayout_spButtonPressedBgColor,
SUtils.COLOR_CONTROL_HIGHLIGHT);
mButtonBarBgColor = a.getColor(R.styleable.ButtonLayout_spButtonBarBgColor,
Color.TRANSPARENT);
setBackgroundColor(mButtonBarBgColor);
if (presentation == 0 /* mode: Button */) {
bPositive.setVisibility(View.VISIBLE);
bNegative.setVisibility(View.VISIBLE);
bPositive.setText(res.getString(R.string.ok));
bNegative.setText(res.getString(R.string.cancel));
SUtils.setViewBackground(bPositive,
SUtils.createButtonBg(context, bgColor,
pressedBgColor));
SUtils.setViewBackground(bNegative,
SUtils.createButtonBg(context, bgColor,
pressedBgColor));
mPositiveButton = bPositive;
mNegativeButton = bNegative;
} else /* mode: ImageView */ {
ivPositive.setVisibility(View.VISIBLE);
ivNegative.setVisibility(View.VISIBLE);
mIconOverlayColor = a.getColor(R.styleable.ButtonLayout_spIconColor,
SUtils.COLOR_ACCENT);
ivPositive.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);
ivNegative.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);
SUtils.setViewBackground(ivPositive,
SUtils.createImageViewBg(bgColor,
pressedBgColor));
SUtils.setViewBackground(ivNegative,
SUtils.createImageViewBg(bgColor,
pressedBgColor));
mPositiveButton = ivPositive;
mNegativeButton = ivNegative;
}
} finally {
a.recycle();
}
// set OnClickListeners
mPositiveButton.setOnClickListener(this);
mNegativeButton.setOnClickListener(this);
}
void initialize() {
Context context = getContext();
final Resources res = getResources();
final TypedArray a = context.obtainStyledAttributes(R.styleable.ButtonLayout);
if (SUtils.isApi_17_OrHigher()) {
setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
}
setOrientation(HORIZONTAL);
setGravity(Gravity.BOTTOM);
setPadding(res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_start),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_top),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_end),
res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_bottom));
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.sublime_button_panel_layout, this, true);
mSwitcherButton = (Button) findViewById(R.id.buttonSwitcher);
Button bPositive = (Button) findViewById(R.id.buttonPositive);
Button bNegative = (Button) findViewById(R.id.buttonNegative);
ImageView ivPositive = (ImageView) findViewById(R.id.imageViewPositive);
ImageView ivNegative = (ImageView) findViewById(R.id.imageViewNegative);
try {
// obtain float value held by android.R.attr.disabledAlpha
TypedValue typedValueDisabledAlpha = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
typedValueDisabledAlpha, true);
// defaults to 0.5 ~ 122/255
mDisabledAlpha = typedValueDisabledAlpha.type == TypedValue.TYPE_FLOAT ?
(int) (typedValueDisabledAlpha.getFloat() * 255)
: 122;
// buttons or icons?
int presentation = a.getInt(R.styleable.ButtonLayout_spPresentation, 0);
int bgColor = a.getColor(R.styleable.ButtonLayout_spButtonBgColor,
SUtils.COLOR_BUTTON_NORMAL);
int pressedBgColor = a.getColor(R.styleable.ButtonLayout_spButtonPressedBgColor,
SUtils.COLOR_CONTROL_HIGHLIGHT);
mButtonBarBgColor = a.getColor(R.styleable.ButtonLayout_spButtonBarBgColor,
Color.TRANSPARENT);
SUtils.setViewBackground(mSwitcherButton,
SUtils.createButtonBg(context, bgColor,
pressedBgColor));
setBackgroundColor(mButtonBarBgColor);
if (presentation == 0 /* mode: Button */) {
bPositive.setVisibility(View.VISIBLE);
bNegative.setVisibility(View.VISIBLE);
bPositive.setText(res.getString(R.string.ok));
bNegative.setText(res.getString(R.string.cancel));
SUtils.setViewBackground(bPositive,
SUtils.createButtonBg(context, bgColor,
pressedBgColor));
SUtils.setViewBackground(bNegative,
SUtils.createButtonBg(context, bgColor,
pressedBgColor));
mPositiveButton = bPositive;
mNegativeButton = bNegative;
} else /* mode: ImageView */ {
ivPositive.setVisibility(View.VISIBLE);
ivNegative.setVisibility(View.VISIBLE);
mIconOverlayColor = a.getColor(R.styleable.ButtonLayout_spIconColor,
SUtils.COLOR_ACCENT);
ivPositive.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);
ivNegative.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);
SUtils.setViewBackground(ivPositive,
SUtils.createImageViewBg(bgColor,
pressedBgColor));
SUtils.setViewBackground(ivNegative,
SUtils.createImageViewBg(bgColor,
pressedBgColor));
mPositiveButton = ivPositive;
mNegativeButton = ivNegative;
}
} finally {
a.recycle();
}
// set OnClickListeners
mPositiveButton.setOnClickListener(this);
mNegativeButton.setOnClickListener(this);
mSwitcherButton.setOnClickListener(this);
}