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

The following examples show how to use android.view.View#setBackgroundTintList() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: aircon   File: BackgroundTintColorSetter.java    License: 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 Project: DevUtils   File: ViewUtils.java    License: 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 Project: letv   File: ViewCompatLollipop.java    License: Apache License 2.0 4 votes vote down vote up
static void setBackgroundTintList(View view, ColorStateList tintList) {
    view.setBackgroundTintList(tintList);
}