The use of simple Fadingactionbar

Source: Internet
Author: User

This library is not available for Actionbar and toolbar support for the Compat version currently in use, so it is recommended that you do not learn how to use this library.

Address: Https://github.com/ManuelPeinado/FadingActionBar

The result of the above was that I had a half-day's time, and the following conclusion took me another 2 hours.

1. First, do not use V7 's actionbaractivity as the parent in Androidstudio, otherwise the nullpointer exception will occur.

2. The use of inherited from activity temporarily does not support the transparency effect, because if the use of the style of the theme using V7 AppCompat is still a null pointer (anyway, a little actionbar compatible with me this is not good to use)

3. Do not use the Darkactionbar and Noactionbar in the Holo two theme, one will show the white Actionbar (and the font is also white, hollow), a still empty pointer (this is a hand after the conclusion of a trial)

4. It is recommended to find another library (I will continue to look for, if there is no good implementation, I will be able to achieve a simple version of the future)

How to reference the library is not much to say, GitHub on, support Gradle file dependency

How to use:

1 @Override2     protected voidonCreate (Bundle savedinstancestate) {3         Super. OnCreate (savedinstancestate);4 5Fadingactionbarhelper helper =NewFadingactionbarhelper ()6 . Actionbarbackground (R.drawable.ab_background)7 . Headerlayout (R.layout.header)8 . Contentlayout (R.layout.activity_listview);9Setcontentview (Helper.createview ( This));TenHelper.initactionbar ( This); One  AListView ListView =(ListView) Findviewbyid (Android. r.id.list); -arraylist<string> items =LoadItems (r.raw.nyc_sites); -arrayadapter<string> adapter =NewArrayadapter<> ( This, Android. R.layout.simple_list_item_1, items); the Listview.setadapter (adapter); -}

There are three parts involved

Actionbarbackground, background after drop down (actionbar document recommended for Actionbar background using 9patch image)

Headerlayout,demo below the layout of the image display area, the size of this area must accord control, if with the listview below a large area of white space, then may be your image layout and other layouts are referenced after the non-expected size of the layout, you can see in the preview.

Contentlayout is the location of the ListView and other layout, the following highlights the problem here:

<xmlns:android= "http://schemas.android.com/apk/res/android"          Android : id= "@android: id/list"          android:layout_width= "Match_parent"           Android:layout_height= "match_parent"/>

The problem here is that the ListView ID must be at the beginning of Android, using exactly what to refer to the relevant usage in the demo.

The imitation effect is as follows (temporarily unable to add Actionbar initial transparency effect)

The use of simple Fadingactionbar

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.