我尝试了下面的代码 fragment ,但它不适用于 API 21 以下:
editText.getBackground().setColorFilter(editTextColor, PorterDuff.Mode.SRC_IN);
editText.getBackground().mutate().setColorFilter(editTextColor,PorterDuff.Mode.SRC_ATOP);
所以请建议我如何更改 API 14。
最佳答案
使用这个:
Drawable drawable = editText.getBackground();
drawable.setColorFilter(editTextColor, PorterDuff.Mode.SRC_ATOP);
if(Build.VERSION.SDK_INT > 16) {
editText.setBackground(drawable);
}else{
editText.setBackgroundDrawable(drawable);
}
关于android - 以编程方式为最低 API 级别 14 更改 EditText 线条颜色和 EditText 光标颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39484383/