本文整理汇总了Java中android.util.TypedValue.TYPE_LAST_COLOR_INT属性的典型用法代码示例。如果您正苦于以下问题:Java TypedValue.TYPE_LAST_COLOR_INT属性的具体用法?Java TypedValue.TYPE_LAST_COLOR_INT怎么用?Java TypedValue.TYPE_LAST_COLOR_INT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.util.TypedValue
的用法示例。
在下文中一共展示了TypedValue.TYPE_LAST_COLOR_INT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveActionTextColorStateList
public static ColorStateList resolveActionTextColorStateList(
Context context, @AttrRes int colorAttr, ColorStateList fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{colorAttr});
try {
final TypedValue value = a.peekValue(0);
if (value == null) {
return fallback;
}
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
final ColorStateList stateList = a.getColorStateList(0);
if (stateList != null) {
return stateList;
} else {
return fallback;
}
}
} finally {
a.recycle();
}
}
示例2: getActionTextColorStateList
public static ColorStateList getActionTextColorStateList(Context context, @ColorRes int colorId) {
final TypedValue value = new TypedValue();
context.getResources().getValue(colorId, value, true);
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
//noinspection deprecation
return context.getResources().getColorStateList(colorId);
} else {
return context.getColorStateList(colorId);
}
}
}
示例3: setOnClick
private View setOnClick(@IdRes int viewID, Class aActivity) {
View view = getActivity().findViewById(viewID);
if(getActivity().getClass() == aActivity) {
// Get the attribute highlight color
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.navigationDrawerHighlighted, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
int color = a.data;
view.setBackgroundColor(color);
}
setCloseDrawerOnClick(view, mDrawerLayout, containerView);
} else {
setStandardOnClick(view, getActivity(), aActivity, mDrawerLayout, containerView);
}
return view;
}
示例4: retrieveNavigationViewThemeColor
/**
* Looks are current theme and retrieves the color attribute
* for the given set theme.
*
* @param context to retrieve the set theme and resolved attribute and then color res Id with {@link ContextCompat}
* @return color resource identifier for primary theme color
*/
public static int retrieveNavigationViewThemeColor(Context context, int resId) {
TypedValue outValue = obtainTypedValue(context, resId);
if (outValue.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& outValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return outValue.data;
} else {
return ContextCompat.getColor(context, outValue.resourceId);
}
}
示例5: getColorFromAttrs
public static int getColorFromAttrs(int resId, Context context, String defaultColor) {
TypedValue a = new TypedValue();
context.getTheme().resolveAttribute(resId, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return a.data;
} else {
return Color.parseColor(defaultColor);
}
}
示例6: factory
public ResScalarValue factory(int type, int value, String rawValue) throws IOException {
switch (type) {
case TypedValue.TYPE_NULL:
return new ResReferenceValue(mPackage, 0, null);
case TypedValue.TYPE_REFERENCE:
return newReference(value, rawValue);
case TypedValue.TYPE_ATTRIBUTE:
return newReference(value, rawValue, true);
case TypedValue.TYPE_STRING:
return new ResStringValue(rawValue, value);
case TypedValue.TYPE_FLOAT:
return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue);
case TypedValue.TYPE_DIMENSION:
return new ResDimenValue(value, rawValue);
case TypedValue.TYPE_FRACTION:
return new ResFractionValue(value, rawValue);
case TypedValue.TYPE_INT_BOOLEAN:
return new ResBoolValue(value != 0, value, rawValue);
case 0x07:
return newReference(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return new ResColorValue(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return new ResIntValue(value, rawValue, type);
}
throw new IOException("Invalid value type: " + type);
}
示例7: setThemeBackground
private void setThemeBackground(View view) {
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
view.setBackgroundColor(a.data);
} else {
try {
Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId, getActivity().getTheme());
ViewCompat.setBackground(view, d);
} catch (Resources.NotFoundException ignore) {
}
}
}
示例8: getColorAttribute
/**
* Finds and returns an attribute color. If it was not found the method returns the default color
*/
public static int getColorAttribute(@AttrRes int attribute, @ColorRes int defaultColor, Context context) {
TypedValue a = new TypedValue();
context.getTheme().resolveAttribute(attribute, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return a.data;
} else {
return ContextCompat.getColor(context, defaultColor);
}
}
示例9: onBindViewHolder
/**
* Called by RecyclerView to display the data at the specified position.
* @param holder RecycleViewHolder
* @param position - int
*/
@Override public void onBindViewHolder(final MapLegendViewHodler holder, final int position) {
final LegendInfo legendInfo = mLegendInfoList.get(position);
holder.legendName.setText(legendInfo.getName());
final Symbol symbol = legendInfo.getSymbol();
final TypedValue a = new TypedValue();
final int color;
// Match the background color of the bitmap to the background of the theme.
mContext.getTheme().resolveAttribute(android.R.attr.colorBackground, a, true);
color =
a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT ? a.data : Color.WHITE;
final ListenableFuture<Bitmap> future = symbol.createSwatchAsync(mContext, color);
future.addDoneListener(new Runnable() {
@Override public void run() {
try {
final Bitmap bitmap = future.get();
holder.legendSymbol.setImageBitmap(bitmap);
} catch (ExecutionException | InterruptedException e) {
Log.e(TAG, e.getMessage());
}
}
});
}
示例10: init
private void init(){
try {
mBoarderPaint = new Paint();
mBoarderPaint.setStyle(Paint.Style.STROKE);
if (this.isSelected()) {
mBoarderPaint.setColor(Color.BLUE);
} else {
mBoarderPaint.setColor(Color.GRAY);
}
mBackgroundPaint = new Paint();
mBackgroundPaint.setStyle(Paint.Style.FILL);
int color = android.R.color.background_light;
TypedValue a = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT)
color = a.data; // windowBackground is a color
mBackgroundPaint.setColor(color);
mPrimaryDarkPaint = new Paint();
mPrimaryDarkPaint.setStyle(Paint.Style.FILL);
mPrimaryDarkPaint.setColor(ContextCompat.getColor(getContext(), mTheme.getPrimaryDarkColor()));
mPrimaryPaint = new Paint();
mPrimaryPaint.setStyle(Paint.Style.FILL);
mPrimaryPaint.setColor(ContextCompat.getColor(getContext(), mTheme.getPrimaryColor()));
mAccentPaint = new Paint();
mAccentPaint.setStyle(Paint.Style.FILL);
mAccentPaint.setColor(ContextCompat.getColor(getContext(), mTheme.getAccentColor()));
mAccentPaint.setAntiAlias(true);
mAccentPaint.setDither(true);
}catch (Exception ex){
ex.printStackTrace();
}
}
示例11: getAttributeValue
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);
}
示例12: getAttributeValue
public 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);
}
示例13: isColor
private static boolean isColor(int type) {
return type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT;
}