The following content is original, welcome reprint, Reprint please specify
From every day blog: http://www.cnblogs.com/tiantianbyconan/p/4474748.html
Rapidfloatingactionbutton
Google launched the Materialdesign design language, which is part of Floatingactionbutton, but Google did not provide an official Floatingactionbutton control, online to find a few trial, But I never found the right one, so I had plenty of it.
Rapidfloatingactionbutton (hereinafter referred to as Rfab) is a quick implementation of the floating Action button.
GitHub Address:Https://github.com/wangjiegulu/RapidFloatingActionButton
How to use:
Depend on:
Androidbucket (https://github.com/wangjiegulu/AndroidBucket): Basic Toolkit
Androidinject (https://github.com/wangjiegulu/androidInject): annotation Framework
Activity_main.xml:
1<Com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout2Xmlns:rfal= "Http://schemas.android.com/apk/res-auto"3Android:id= "@+id/activity_main_rfal"4Android:layout_width= "Match_parent"5android:layout_height= "Match_parent"6Rfal:rfal_frame_color= "#ffffff"7Rfal:rfal_frame_alpha= "0.7"8>9<Com.wangjie.rapidfloatingactionbutton.RapidFloatingActionButtonTenxmlns:rfab= "Http://schemas.android.com/apk/res-auto" OneAndroid:id= "@+id/activity_main_rfab" AAndroid:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" -Android:layout_alignparentright= "true" theAndroid:layout_alignparentbottom= "true" -android:layout_marginright= "15DP" -Android:layout_marginbottom= "15DP" -Android:padding= "8DP" +Rfab:rfab_size= "Normal" -rfab:rfab_drawable= "@drawable/rfab__drawable_rfab_default" +Rfab:rfab_color_normal= "#37474f" ARfab:rfab_color_pressed= "#263238" atRfab:rfab_shadow_radius= "7DP" -Rfab:rfab_shadow_color= "#999999" -rfab:rfab_shadow_dx= "0DP" -Rfab:rfab_shadow_dy= "5DP" -/> -</com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout>
In the need to add rfab outermost use <com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout> , the button uses<com.wangjie.rapidfloatingactionbutton.RapidFloatingActionButton>
Attribute Interpretation Rapidfloatingactionlayout:
Rfal_frame_color: Expands the color of the outer overlay at Rfab, the default is pure white Rfal_frame_alpha: Expands the transparency of the outer cover layer when Rfab (0 ~ 1), the default is 0.7
Rapidfloatingactionbutton:
Rfab_size:rfab size, only two sizes are supported (Material design specification): normal: Diameter 56DP Mini: an icon in the middle of 40dp rfab_drawable:rfab diameter, The default is a "+" icon rfab_color_normal:rfab the color of the normal state of the background. The default is the color of the touch pressed state of the white rfab_color_pressed:rfab background. The default color is the shadow radius of the "#dddddd" rfab_shadow_radius:rfab. The default is 0, which indicates a shadow color without shadow Rfab_shadow_color:rfab. The default is transparent, and if Rfab_shadow_radius is 0, the property is invalid rfab_shadow_dx:rfab the shadow X-axis offset. The default is 0 rfab_shadow_dy:rfab of the shadow y-axis offset. Default is 0
Mainactivity:
1 @AILayout (R.layout.activity_main)2 Public classMainactivityextendsAiactionbaractivityImplementsRapidfloatingactioncontentlabellist.onrapidfloatingactioncontentlistener {3 4 @AIView (R.id.activity_main_rfal)5 Privaterapidfloatingactionlayout rfalayout;6 @AIView (R.id.activity_main_rfab)7 PrivateRapidfloatingactionbutton rfabtn;8 PrivateRapidfloatingactionbuttonhelper Rfabhelper;9 Ten @Override One protected voidonCreate (Bundle savedinstancestate) { A Super. OnCreate (savedinstancestate); - -Rapidfloatingactioncontentlabellist rfacontent =Newrapidfloatingactioncontentlabellist (context); theRfacontent.setonrapidfloatingactioncontentlistener ( This); -list<rfaclabelitem> items =NewArraylist<>(); -Items.Add (NewRfaclabelitem<integer>() -. SetLabel ("Github:wangjiegulu") + . Setresid (R.drawable.ic_launcher) -. Seticonnormalcolor (0xffd84315) +. Seticonpressedcolor (0xffbf360c) A. Setwrapper (0) at ); -Items.Add (NewRfaclabelitem<integer>() -. SetLabel ("[Email protected]") - . Setresid (R.drawable.ic_launcher) -. Seticonnormalcolor (0xff4e342e) -. Seticonpressedcolor (0xff3e2723) in. Setwrapper (1) - ); toItems.Add (NewRfaclabelitem<integer>() +. SetLabel ("Wangjie") - . Setresid (R.drawable.ic_launcher) the. Seticonnormalcolor (0xff056f00) *. Seticonpressedcolor (0xff0d5302) $. Setwrapper (2)Panax Notoginseng ); -Items.Add (NewRfaclabelitem<integer>() the. SetLabel ("Compose") + . Setresid (R.drawable.ic_launcher) A. Seticonnormalcolor (0xff283593) the. Seticonpressedcolor (0xff1a237e) +. Setwrapper (3) - ); $ rfacontent $ . Setitems (items) -. Seticonshadowradius (abtextutil.dip2px (context, 5)) -. Seticonshadowcolor (0xff999999) the. Seticonshadowdy (abtextutil.dip2px (context, 5)) - ;Wuyi theRfabhelper =NewRapidfloatingactionbuttonhelper ( - context, Wu Rfalayout, - rfabtn, About rfacontent $ ). Build (); - - } - A @Override + Public voidOnrfacitemlabelclick (intposition, Rfaclabelitem Item) { theToast.maketext (GetContext (), "clicked Label:" +position, Toast.length_short). Show (); - rfabhelper.togglecontent (); $ } the the @Override the Public voidOnrfacitemiconclick (intposition, Rfaclabelitem Item) { theToast.maketext (GetContext (), "clicked Icon:" +position, Toast.length_short). Show (); - rfabhelper.togglecontent (); in } the}
In addition to the and beyond set in XML RapidFloatingActionLayout RapidFloatingActionButton , RapidFloatingActionContent the implementation class is required to populate and specify the content and form of the Rfab.
Here is a quick RapidFloatingActionContent implementation solution for: RapidFloatingActionContentLabelList . You can add multiple item (Rfaclabelitem, of course, do not recommend adding too many item, resulting in more than one screen), and then set each item's color, icon, shadow, or even animation.
Its effect can refer to the top slice or Google's inbox effect.
In addition, you need to use it RapidFloatingActionButtonHelper to combine all of these scattered components.
About Extensions:
If you don't like the default offer RapidFloatingActionContentLabelList , you can theoretically extend your own content style. The method is inherited com.wangjie.rapidfloatingactionbutton.RapidFloatingActionContent , then initializes the content layout and style, and invokes the method of the parent class setRootView(xxx); . If you need to add animations, you can override the following methods:
Public void onexpandanimator (Animatorset animatorset); Public void oncollapseanimator (Animatorset animatorset);
Add the required animator to the Animatorset
另外,作者也会不定期增加更多的RapidFloatingActionContent的扩展
License
Copyright: Wang jielicensed under the Apache License, Version 2.0 (the "License"); Compliance with the license.you could obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless R Equired by applicable-law or agreed-to-writing, softwaredistributed under the License is distributed on a "as is" BASI S,without warranties or CONDITIONS of any KIND, either express or implied. See the License for the specific language governing permissions andlimitations under the License.
[Android] Rapidfloatingactionbutton Framework officially released