本文整理汇总了Java中android.widget.EditText.setBackgroundTintList方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setBackgroundTintList方法的具体用法?Java EditText.setBackgroundTintList怎么用?Java EditText.setBackgroundTintList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setBackgroundTintList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editTextFocusChange
import android.widget.EditText; //导入方法依赖的package包/类
private static View.OnFocusChangeListener editTextFocusChange(final EditText editText, final Context context){
return new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if(hasFocus || !editText.getText().toString().equals("")){
editText.setBackgroundTintList(
ColorStateList.valueOf(
context.getResources()
.getColor(FOCUS_COLOR)));
}else{
editText.setBackgroundTintList(
ColorStateList.valueOf(
context.getResources()
.getColor(LEAVE_COLOR)));
}
}
};
}
示例2: setTint
import android.widget.EditText; //导入方法依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color, boolean useDarker) {
final ColorStateList editTextColorStateList = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed, -android.R.attr.state_focused},
new int[]{}
}, new int[]{
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light),
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
color
});
if (editText instanceof AppCompatEditText) {
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
setCursorTint(editText, color);
}
示例3: setTint
import android.widget.EditText; //导入方法依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color, boolean useDarker) {
final ColorStateList editTextColorStateList = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed, -android.R.attr.state_focused},
new int[]{}
}, new int[]{
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light),
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
color
});
if (editText instanceof TintableBackgroundView) {
ViewCompat.setBackgroundTintList(editText, editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
setCursorTint(editText, color);
}
示例4: setTint
import android.widget.EditText; //导入方法依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color) {
ColorStateList editTextColorStateList = createEditTextColorStateList(editText.getContext(), color);
if (editText instanceof AppCompatEditText) {
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
setCursorTint(editText, color);
}
示例5: tint
import android.widget.EditText; //导入方法依赖的package包/类
/**
* Tint the edit text
*
* @param editText the edit text
* @param color the color
*/
@SuppressWarnings("RestrictedApi")
public static void tint(@NonNull EditText editText, @ColorInt int color) {
ColorStateList editTextColorStateList = createEditTextColorStateList(editText.getContext(), color);
if (editText instanceof AppCompatEditText) {
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
tint((TextView) editText, color);
}
示例6: setUnderlineColor
import android.widget.EditText; //导入方法依赖的package包/类
public static void setUnderlineColor(EditText editText, int color) {
ColorStateList colorStateList = ColorUtils.getPureColorList(color);
editText.setBackgroundTintList(colorStateList);
}