Android numberpicker Default Appearance modification

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.