[英]How To Change The Bottom Line EditText Color?
I have an EditText
in an AlertDialog
and the bottom line color is not what I want, and I can't figure out how to change it. 我在AlertDialog
有一个EditText
,底线颜色不是我想要的,我无法弄清楚如何更改它。
Here is what I have so far. 这是我到目前为止所拥有的。
AlertDialog.Builder adb = new AlertDialog.Builder(new ContextThemeWrapper(MainActivity.this, R.style.EditTextAlertDialog));
adb.setTitle("Title");
inputET = new EditText(this);
inputET.setInputType(InputType.TYPE_CLASS_TEXT);
inputET.setTextColor(getResources().getColor(android.R.color.white));
inputET.setHighlightColor(getResources().getColor(android.R.color.white)); //This should change it, but it's not.
adb.setView(inputET);
adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
adb.show();
For some weird reason that is not working, setHightlightColor
should be it. 对于一些不起作用的奇怪原因, setHightlightColor
应该是它。
You can create a style for your dialog. 您可以为对话框创建样式。
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/yourEditTextColor</item>
</style>
And then add it while creating your Dialog 然后在创建Dialog时添加它
AlertDialog.Builder adb = new AlertDialog.Builder(new ContextThemeWrapper(MainActivity.this, R.style.MyDialogTheme));
您需要为该用途设置背景色调:
inputET.setBackgroundTintList(ColorStateList.valueOf(intColorCode));
在xml文件下将它放入你的EditText: app:backgroundTint="@color/black"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.