繁体   English   中英

如何在DatePickerDialog Android中更改字体

[英]How to change font in DatePickerDialog android

我想在DatePickerDialog中更改字体,但是我不知道要设置它

如何在DatePickerDialog android中更改字体? 谢谢!

DatePickerDialog datePickerDialog = new DatePickerDialog(
    getContext(), this, startYear, starthMonth, startDay);

尝试这个

TextView titleTextView = (TextView) datePickerDialog.findViewById(android.R.id.title);
titleTextView.setText("Nilesh Rathod");
titleTextView.setTextSize(20);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/BLACKROSE.TTF");
titleTextView.setTypeface(tf);
datePickerDialog.show();

这也

DatePickerDialog datePicker = (DatePicker) findViewById(R.id.datePicker1);
LinearLayout layout1 = (LinearLayout) datePicker.getChildAt(0);
LinearLayout layout = layout1.getChildAt(0);

// day
LinearLayout day = (LinearLayout) layout.getChildAt(0);
setNumberPicker(day);

// month
LinearLayout month = (LinearLayout) layout.getChildAt(1);
setNumberPicker(month);

// year
LinearLayout year = (LinearLayout) layout.getChildAt(2);
setNumberPicker(year);

现在使用此方法更改类型

private void setNumberPicker(LinearLayout ll) {
    ((ImageButton) ll.getChildAt(0)).setBackgroundResource(R.drawable.plus_button);
    ((ImageButton) ll.getChildAt(2)).setBackgroundResource(R.drawable.minus_button);

    EditText et = (EditText) ll.getChildAt(1);
    et.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    Typeface tf = Typeface.createFromAsset(getAssets(),   "fonts/BLACKROSE.TTF");
    et.setTypeface(tf);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM