gpt4 book ai didi

java - 如何在AlertDialog edittext中设置fontfamily?

转载 作者:行者123 更新时间:2023-12-01 19:32:24 24 4
gpt4 key购买 nike

我不知道如何为alertdialog editext设置fontfamily。

 AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Project name");
LinearLayout linearLayout = new LinearLayout(MainActivity.this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setPadding(10, 10, 10, 10);
final EditText editText = new EditText(MainActivity.this);
editText.setHint("Enter your project name");//here how to change text fontfamily
linearLayout.addView(editText);
builder.setView(linearLayout);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String text = editText.getText().toString();

}
});

builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

}
});

builder.create().show();
}
});

我尝试使用 TypeFace 但它不起作用。如果你能帮助我,那就太好了,我会给你一票。

最佳答案

尝试这两行并检查它是否工作。

Typeface typeface=Typeface.create("font-family",Typeface.BOLD_ITALIC);
editText.setTypeface(typeface);

关于java - 如何在AlertDialog edittext中设置fontfamily?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59232272/

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