Java Code Examples for android.view.View#setBackgroundTintList()

The following examples show how to use android.view.View#setBackgroundTintList() . 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: BackgroundTintColorSetter.java    From aircon with MIT License 5 votes vote down vote up
@Override
protected void setAttr(final View view, final int color) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		view.setBackgroundTintList(ColorStateList.valueOf(color));
	}
	else {
		view.getBackground()
		    .setColorFilter(color, PorterDuff.Mode.SRC_IN);
	}
}
 
Example 2
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 设置背景着色颜色
 * @param view {@link View}
 * @param tint 着色颜色
 * @return {@link View}
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static View setBackgroundTintList(final View view, final ColorStateList tint) {
    if (view != null) {
        try {
            view.setBackgroundTintList(tint);
        } catch (Exception e) {
            LogPrintUtils.eTag(TAG, e, "setBackgroundTintList");
        }
    }
    return view;
}
 
Example 3
Source File: ViewCompatLollipop.java    From letv with Apache License 2.0 4 votes vote down vote up
static void setBackgroundTintList(View view, ColorStateList tintList) {
    view.setBackgroundTintList(tintList);
}