gpt4 book ai didi

java - 如何更改EditText底线颜色?

转载 作者:行者123 更新时间:2023-12-02 05:07:26 25 4
gpt4 key购买 nike

我在 AlertDialog 中有一个 EditText,底线颜色不是我想要的,而且我不知道如何更改它。

这是我到目前为止所拥有的。

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

由于某些奇怪的原因不起作用,应该是 setHightlightColor

最佳答案

您可以为对话框创建样式。

<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/yourEditTextColor</item>
</style>

然后在创建对话框时添加它

AlertDialog.Builder adb = new AlertDialog.Builder(new ContextThemeWrapper(MainActivity.this, R.style.MyDialogTheme));

关于java - 如何更改EditText底线颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56342726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com