cuốn sách gpt4 ai đã làm

android - Thay đổi họ phông chữ của EditText setError()

In lại Tác giả: Vũ trụ không gian Thời gian cập nhật: 2023-11-03 13:25:22 hai mươi bốn 4
mua khóa gpt4 Nike

tôi nghĩThay đổiEditText setError() họ phông chữ.

我已经试过了:

editText.setError(Html.fromHtml("xin chào"));

Tôi muốn thay đổi họ phông chữ của thông báo lỗi trên điện thoại Samsung khi người dùng chọn phông chữ khác.

Bất kỳ ý tưởng sẽ được đánh giá rất cao.

提前致谢

câu trả lời hay nhất

Bạn có thể thử điều này:

Kiểu chữ typeFaceDefault = Typeface.createFromAsset(getAssets(), "BYekan.ttf");

TextInputLayout inputLayout = (TextInputLayout) view.findViewById(R.id.lyt_input);

SpannableStringBuilder ssbuilder = new SpannableStringBuilder(getString(R.string.err_wrong_input));
ssbuilder.setSpan(new CustomTypefaceSpan("", Hoạt độngMain.typeFaceDefault), 0, ssbuilder.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
inputLayout.setError(ssbuilder);

Sau đó, phần tử của bạn cũng chứa tệp này:

lớp công khai CustomTypefaceSpan mở rộng TypefaceSpan {

riêng cuối cùng Kiểu chữ newType;

public CustomTypefaceSpan(Họ chuỗi, kiểu chữ) {
siêu(gia đình);
newType = loại;
}

@Ghi đè
public void updateDrawState(TextPaint ds) {
áp dụngCustomTypeFace(ds, newType);
}

@Ghi đè
public void updateMeasureState(TextPaint sơn) {
applyCustomTypeFace(paint, newType);
}

khoảng trống tĩnh riêng áp dụngCustomTypeFace(Sơn sơn, Kiểu chữ tf) {
int oldStyle;
Kiểu chữ old = Paint.getTypeface();
nếu (cũ == null) {
oldStyle = 0;
} khác {
oldStyle = old.getStyle();
}

int giả = oldStyle & ~tf.getStyle();
if ((giả & Kiểu chữ. BÓNG) != 0) {
Paint.setFakeBoldText(true);
}

if ((fake & Typeface.ITALIC) != 0) {
Paint.setTextSkewX(-0.25f);
}

Paint.setTypeface(tf);
}
}

Về android - Thay đổi họ phông chữ của EditText setError(), chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/21256559/

hai mươi bốn 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress