Android4.0 Settings Interface changes summary (ii)

Source: Internet
Author: User

In January this year. Have to share with you to give android4.0+ system settings changes: Android4.0 Settings Interface Changes Summary

Six months after the lapse. Look back at the changes at that time. In fact there are a lot of problems, for example:

①. Fillet item affects third-party applications (because I am a preferencegroupadapter under the framework of a public change).

②. Settings cannot be toggled by screen.

Because at that time the customer urged the more urgent, did not take into account. Just later. We are in the new platform, there is once again intact, and today to share with you.


Solution to the first problem:

①. Add a Boolean variable misroundcornerpreference in preferencegroupadapter , assuming true to return a fillet-treated view, or false to return the original view. The code is as follows:

        Start by liweiping 20140523 view view = Preference.getview (Convertview, parent);        if (!misroundcornerpreference) {return view;                } else {if (mpreferencelistbackgroundindex.get (position) = = Single_line_round_corner_background) {            View.setbackgroundresource (Com.android.internal.r.drawable.easy_pref_item_single); } else if (mpreferencelistbackgroundindex.get (position) = = Top_round_corner_background) {View.setbackgroun            Dresource (Com.android.internal.r.drawable.easy_pref_item_top); } else if (mpreferencelistbackgroundindex.get (position) = = Center_rectangle_background) {View.setbackgroun            Dresource (Com.android.internal.r.drawable.easy_pref_item_center); } else if (mpreferencelistbackgroundindex.get (position) = = Bottom_round_corner_background) {view.setbackgr            Oundresource (Com.android.internal.r.drawable.easy_pref_item_bottom); }            return view; }//end by Liweiping 20140523

②.misroundcornerpreference This variable is obtained by reading the properties in the Attrs.xml, which is read when the Preferencegroupadapter object is instantiated, the detail code such as the following:

    Public Preferencegroupadapter (Preferencegroup preferencegroup) {        mpreferencegroup = Preferencegroup;        If This group Gets or loses any children, let us know        Mpreferencegroup.setonpreferencechangeinternallistener (this) ;        Mpreferencelist = new arraylist<preference> ();        mpreferencelayouts = new arraylist<preferencelayout> ();        Start by liweiping 20140523        TypedArray a = Mpreferencegroup.getcontext (). Obtainstyledattributes (NULL,                R.styleable.roundcornerpreference, 0, 0);        Misroundcornerpreference = A.getboolean (R.styleable.roundcornerpreference_isroundcorner, false);                                                            A.recycle ();        End by liweiping 20140523        syncmypreferences ();    }

③. Need to add a property in Attrs.xml, such as the following (another property is a new ListView style I added, temporarily ignore it):

    <declare-styleable name= "Roundcornerpreference" >        <attr name= "Isroundcorner" format= "boolean"/>    <attr name= "listviewstyletopwise" format= "reference"/>    </declare-styleable>

④. We add a theme in the Theme.xml (note in the Public.xml file, otherwise the compilation may error, the topic cannot be found) inherit the system's own theme. Let's say Theme.holo or Theme.Holo.Light, assign the Isroundcorner property in Attrs.xml to true in the child node of the topic.

For example, as seen below (I have again assigned the other properties of the system, please ignore):

    <style name= "Theme.Holo.Light.Topwise" >    <item name= "Listseparatortextviewstyle" > @android: style/ widget.holo.light.textview.listseparator.topwise</item>        <item name= "Textappearancemedium" >@ android:style/textappearance.holo.light.medium.topwise</item>        <item name= "IsRoundCorner" >true </item>    <item name= "listviewstyletopwise" > @android:style/widget.holo.light.listview.topwise< /item>    <item name= "textcolorsecondary" > @android:d rawable/selector_text_summary</item>    <item name= "Textappearancesmall" > @android:style/textappearance.holo.light.small.topwise</item>    </style>

⑤. Change the theme of our settings app to the new Theme.Holo.Light.Topwise. This is basically done, and the fillet style selection only affects the Settings app. Other apps will have the same style as before.


Summary: Assume that the reader can very well understand the attrs.xml, Styles.xml, Themes.xml, public.xml the direct relationship between the files. It should be very easy to think of this way to achieve a variety of configurations, diverse themes.

In fact. Refer to the design of mainstream manufacturers such as Millet, OPPO, Meizu, they have their own package of a framework, that is, their own system applications using their own framework. Third-party apps use the native framework. This can be very convenient to add a variety of new features, new interfaces. The same time will not affect third-party applications.

This is a very good way, but it is also flawed: the use of mobile space will increase (this is the 16GB, 64GB of mobile phones are actually bucket). Therefore, this is also a trend.


Well, today and everyone analysis here, about the second issue of the changes, the next analysis.

Thank you!

If there are any questions, please leave a message to discuss.


Android4.0 Settings Interface changes summary (ii)

Related Article

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.