本文整理匯總了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);
}