我想改变字体在DatePickerDialog,但我不知道将其设置如何改变字体在Android的DatePickerDialog
如何改变字体在Android的DatePickerDialog? 谢谢!
DatePickerDialog datePickerDialog = new DatePickerDialog(
getContext(), this, startYear, starthMonth, startDay);
我想改变字体在DatePickerDialog,但我不知道将其设置如何改变字体在Android的DatePickerDialog
如何改变字体在Android的DatePickerDialog? 谢谢!
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);
}
in line'LinearLayout layout1 =(LinearLayout)datePicker.getChildAt(0);'不能调用'getChildAt(0)' –
@ ARR.s只需在xml布局中添加此DatePickerDialog –
@ARR.s **看完后在源代码中,Datepicker小部件包含3个NumberPicker小部件(用于日,月,年),而小部件又包含TextView。因此,您必须在DatePicker内的NumberPickers内部为TextView设置字体。 我认为你必须获得NumberPicker和DatePicker的源码,并修改源代码来实现这一点,说起来容易做起来难。** –
使用这个答案这里给出HTTPS改变类型:计算器//的.com /一个/ 290144 75/4571925 –
此链接可能会帮助您http://androiddatepicker.blogspot.in/ –
为您的日期选择器添加自定义*样式并将其添加到布局中。 – Orvenito