Several compatibility issues with APPCOMPAT_V7 21.0.0d

Source: Internet
Author: User

1. Implement a new Actionbardrawertoggle animation

Actionbardrawertoggle Use the latest Appcompat_v7 21 will appear a very handsome animation, the use of Androidstudio under the first add compile

dependencies {    Compile filetree (dir: ' Libs ', include: [' *.jar '])    compile ' com.android.support:appcompat-v7 : 21.0.0 '}

Then direct the Actionbardrawertoggle impot to use the import android.support.v7.app.ActionBarDrawerToggle;

The subsequent construction method can be used

Mdrawertoggle = new Actionbardrawertoggle (this, Mdrawerlayout, toolbar, r.string.app_name, r.string.app_name);

Of course you need a toolbar.


2. Use toolbar instead of Actionbar

Android L added a new control to step-by-step replacement Actionbar,toolbar has a more flexible extension, completely replaces the Actionbar, and has its own flexibility as a view. Just a little inconvenient, toolbar needs to be declared in every activity, either in XML or in code

    • Modify a Theme
<resources>    <style name= "Apptheme" parent= "Theme.appcompat" >        <!--Customize your Theme here.- -        <item name= "Windowactionbar" >false</item>        <item name= "Android:windownotitle" > True</item>        <!--Actionbar Color--        <item name= "colorprimary" > @color/accent_material_ Dark</item>        <!--Status bar color-->        <item name= "Colorprimarydark" > @color/accent_ Material_light</item>        <!--window color-->        <item name= "Android:windowbackground" > @color /dim_foreground_material_dark</item>    </style></resources>
If you used the Actionbarpulltorefresh control this time will find that the progress bar and the bottom side have two DP interval, if you use toolbar, then you can control the height of Actionbar, Of course, you can modify the Actionbarpulltorefresh source code to solve this problem
    • Add toolbar to the layout
    <android.support.v7.widget.toolbar        android:id= "@+id/toolbar"        android:layout_width= "Match_parent"        android:layout_height= "wrap_content"        android:minheight= "? attr/actionbarsize"        android:background= " ? attr/colorprimary "        ></android.support.v7.widget.Toolbar>

Toolbar Toolbar = (Toolbar) Findviewbyid (R.id.toolbar); Setsupportactionbar (toolbar);

This gets a replacement for the Actionbar toolbar, the test found that the internal fragment Getactionbar can be used directly, because in Activiyty toolbar is set to Actionbar, So the internal fragment of the Actionbar can be used exactly as before. Of course, you can also set your own toolbar in the fragment.
the problem of 3.Actionbar Listmodel dislocationActionbar.navigation_mode_list after replacing the AppCompat on the 4.x display will appear dislocation, and show that this method has been discarded, such as
The solution is to use Tintspinner instead of spinner, it is strange that tintspinner in the official website can not find the relevant information, of course, it is also in the Android.support.v7.internal.widget package, open to see the source found
public class Tintspinner extends Android.widget.Spinner {    private static final int[] Tint_attrs;    Public Tintspinner (Android.content.Context Context) {/* Compiled code *    /} public Tintspinner ( Android.content.Context Context, Android.util.AttributeSet attrs) {/* Compiled code *    /} public Tintspinner (Android . Content. Context context, Android.util.AttributeSet attrs, int defstyleattr) {/* Compiled code */}}

He inherited the spinner, but did not make any changes, good wonders, replaced and then did solve the problem.


4. To be Continued ...






Several compatibility issues with APPCOMPAT_V7 21.0.0d

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.