Numberpicker is a control introduced after Android3.0, in the subsequent Timepicker and DatePicker time control inside the reference, Numberpicker itself does not provide an interface to the developer to modify its default appearance, this continuation of the previous blog content ( Adjusts the size and style of the timepicker,datepicker, providing a way to modify the default appearance of Numberpicker (mainly to modify the font size, color). If you are using Android3.0 later, and you only need to modify the Numberpicker font, then this is the most lazy way. The effect is still first.
The red box on the left is a Numberpicker control that modifies its font and color.
The way to do this is to use Customnumberpicker to inherit the Numberpicker control and modify its properties when its child controls EditText loaded, as detailed below:
PublicClass CustomnumberpickerExtends Numberpicker { PublicCustomnumberpicker (context context, AttributeSet Attrs) {Super(context, attrs); }@OverridePublicvoidAddView (View child) {Super. AddView (child); Updateview (child); }@OverridePublicvoid AddView (View child,IntIndex, android.view.ViewGroup.LayoutParams params) {Super. AddView (Child, index, params); Updateview (child); }@OverridePublicvoid AddView (View child, Android.view.ViewGroup.LayoutParams params) {super.addview (child, params); Updateview (child);} public void Updateview (view view) {if (view instanceof EditText) {// Here Modify the properties of the font 12
Then the XML file will be replaced with Customnumberpicker Numberpicker.
But most of the applications need to support the previous version of Android3.0, this time you need to write your own Numberpicker control, fortunately this part of the work, has been done for you, you just need to take doctrine.
The Numberpicker control from GitHub, which you can use after you click Download. It is written according to the Android source code, combined with the use of the library, and achieved after compatibility with the Android version. Because they have not been used, so do not write more, there is a need for students to download the use.
Android numberpicker Default Appearance modification