android.widget.EditText.setBackgroundTintList()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中android.widget.EditText.setBackgroundTintList()方法的一些代码示例,展示了EditText.setBackgroundTintList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EditText.setBackgroundTintList()方法的具体详情如下:
包路径:android.widget.EditText
类名称:EditText
方法名:setBackgroundTintList

EditText.setBackgroundTintList介绍

暂无

代码示例

代码示例来源:origin: garretyoder/app-theme-engine

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);
}

代码示例来源:origin: xuancao/DynamicSkin

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_disabled_edittext_dark : R.color.ate_disabled_edittext_light),
      Util.resolveColor(editText.getContext(), R.attr.colorControlNormal),
      color
  });
  if (editText instanceof AppCompatEditText) {
    ((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
  } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    editText.setBackgroundTintList(editTextColorStateList);
  }
}

代码示例来源:origin: pranavpandey/dynamic-support

/**
 * Tint an {@link EditText} by changing its cursor, hint, etc. colors according to the
 * supplied color.
 *
 * @param editText The edit text to be colorized.
 * @param color The color to be used.
 */
public static void setColor(@NonNull EditText editText, @ColorInt int color) {
  ColorStateList editTextColorStateList = DynamicResourceUtils.getColorStateList(color);
  if (editText instanceof TintableBackgroundView) {
    ViewCompat.setBackgroundTintList(editText, editTextColorStateList);
  } else if (DynamicVersionUtils.isLollipop()) {
    editText.setBackgroundTintList(editTextColorStateList);
  }
  setCursorColor(editText, color);
}

代码示例来源:origin: h4h13/RetroMusicPlayer

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);
}

相关文章

微信公众号

最新文章

更多

EditText类方法