Open Source Library Guillotine usage parsing

Source: Internet
Author: User

Reprint Please indicate the source: Wang 亟亟 's way of Daniel
Recently in busy job-hopping, led to many days did not knock code, yesterday just see this library finally straightened out and then write an article (before Gradle how all have problems, really pit)
See more of the same kind of drawer in the form of the main menu and content part, see this menu or a new feeling it, words not to say first on.


In general, press the Red/blue button in the upper-left corner and then display the menu and main content.

Git on the project, most of the gradle built package so just match it, the package is very simple, a Lib Package a sample project package. (Take a family to say, can use on the line, good, to see how to use)

to use this library to write a application class and register this class in manifest
PS: Used Slidingmenu's small partners must know, they all want a similar to this class

 Public  class App extends application {    Private Static FinalString Canaro_extra_bold_path ="FONTS/CANARO_EXTRA_BOLD.OTF"; Public StaticTypeface Canaroextrabold;@Override     Public void onCreate() {Super. OnCreate ();    Inittypeface (); }Private void Inittypeface() {canaroextrabold = Typeface.createfromasset (Getassets (), Canaro_extra_bold_path); }}

Daniel also wrote a custom TextView in fact, this class does not matter, we use the time can ignore him

 Public  class canarotextview extends TextView {     Public Canarotextview(Context context) { This(Context,NULL); } Public Canarotextview(context context, AttributeSet attrs) { This(Context, Attrs,0); } Public Canarotextview(context context, AttributeSet attrs,intDEFSTYLEATTR) {Super(Context, attrs, defstyleattr);    Settypeface (App.canaroextrabold); }}

Main activity
Here Daniel used a note to solve his Findviewbyid, class library address http://jakewharton.github.io/butterknife/, here do not explain, but look at it is quite simple, you can later in the project under trial

 Public  class mainactivity extends appcompatactivity {    Private Static Final LongRipple_duration = -;@InjectView(r.id.toolbar) toolbar toolbar;@InjectView(r.id.root) framelayout root;@InjectView(R.id.content_hamburger)    View Contenthamburger; Button Testbuttonbutton;@InjectView(R.id.contentbutton) Button Contentbutton;@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (r.layout.activity); Butterknife.inject ( This);if(Toolbar! =NULL) {Setsupportactionbar (toolbar); Getsupportactionbar (). Settitle (NULL); } View Guillotinemenu = Layoutinflater.from ( This). Inflate (R.layout.guillotine,NULL); Root.addview (Guillotinemenu);NewGuillotineanimation.guillotinebuilder (Guillotinemenu, Guillotinemenu.findviewbyid (R.id.guillotine_hamburger),                Contenthamburger). Setstartdelay (ripple_duration). Setactionbarviewforanimation (Toolbar)        . build ();        Testbuttonbutton = (Button) Guillotinemenu.findviewbyid (R.id.testbutton);    Listener (); }Private void Listener() {Testbuttonbutton.setonclicklistener (NewView.onclicklistener () {@Override             Public void OnClick(View v) {Toast.maketext (mainactivity). This,"Menubutton", Toast.length_short). Show ();        }        }); Contentbutton.setonclicklistener (NewView.onclicklistener () {@Override             Public void OnClick(View v) {Toast.maketext (mainactivity). This,"Contentbutton", Toast.length_short). Show ();    }        }); }}

Logic: Toast A "Contentbutton" on the main page, and then toast a "Menubutton" on the menu page.
We do not need to make any changes to the display layer, the use of copy on the line, very convenient.

Manifest file

<manifest xmlns:android="Http://schemas.android.com/apk/res/android"  package ="Com.yalantis.guillotine.sample">        <applicationandroid:name=". App "android:allowbackup=" true "android:icon=" @mipmap/ic_launcher "  Android:label="@string/app_name"android:theme="@style/apptheme" >                                                <activityandroid:name=". Activity. Mainactivity "android:screenorientation=" Portrait ">                                    <intent-filter>                <action android:name="Android.intent.action.MAIN" />                <category android:name="Android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </Application></manifest>

Source Address: http://yunpan.cn/ccNJpEzA4NZGd access password 7a65
Thank you

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Open Source Library Guillotine usage parsing

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.