Java Code Examples for android.util.TypedValue#TYPE_FLOAT
The following examples show how to use
android.util.TypedValue#TYPE_FLOAT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlManifestReader.java From AndroidPlugin with MIT License | 5 votes |
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); }
Example 2
Source File: RangeSeekBar.java From openshop.io-android with MIT License | 5 votes |
@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)); } }
Example 3
Source File: ManifestReader.java From PluginLoader with Apache License 2.0 | 5 votes |
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); }
Example 4
Source File: Rotate3dAnimation.java From HaiNaBaiChuan with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: AXmlResourceParser.java From LibScout with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: AXMLPrinter.java From Android-Applications-Info with Apache License 2.0 | 5 votes |
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); }
Example 7
Source File: AXmlResourceParser.java From Android-Applications-Info with Apache License 2.0 | 5 votes |
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; }
Example 8
Source File: AXmlResourceParser.java From apkReSign with Apache License 2.0 | 5 votes |
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; }
Example 9
Source File: Rotate3dAnimation.java From pe-protector-moe with GNU General Public License v3.0 | 5 votes |
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; }
Example 10
Source File: ThemeUtilTest.java From msdkui-android with Apache License 2.0 | 5 votes |
@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()); }
Example 11
Source File: AndroidXmlConvertor.java From ghidra with Apache License 2.0 | 5 votes |
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); }
Example 12
Source File: Rotate3dAnimation.java From KAlertDialog with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: XmlBlock.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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!"); }
Example 14
Source File: Resources.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 15
Source File: XmlManifestReader.java From AndroidPlugin with MIT License | 5 votes |
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; }
Example 16
Source File: ManifestReader.java From Android-Plugin-Framework with MIT License | 5 votes |
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); }
Example 17
Source File: Utils.java From butterknife with Apache License 2.0 | 5 votes |
@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"); }
Example 18
Source File: DecisionButtonLayout.java From SublimePicker with Apache License 2.0 | 4 votes |
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); }
Example 19
Source File: Resources.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * 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(); }
Example 20
Source File: ButtonLayout.java From SublimePicker with Apache License 2.0 | 4 votes |
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); }