android - FloatingActionButton submenus -


i achieve fab submenus pushbullet. have no idea how fab being able clicked inside fragment , activity.

this how pushbullet fab looks like: enter image description here

right im doing treat fab menu layout fragment. , initiate fragment when click on fab. however, not able click on fab after fab menu fragment inflated. because fab menu fragment cover on fab button.

anyone have idea how pushbullet it's fab menu???

first add dependencies compile 'com.getbase:floatingactionbutton:1.10.1'

dependencies {     compile filetree(include: ['*.jar'], dir: 'libs')     androidtestcompile('com.android.support.test.espresso:espresso-core:2.2.2', {         exclude group: 'com.android.support', module: 'support-annotations'     })     compile 'com.android.support:appcompat-v7:25.3.1'     compile 'com.android.support.constraint:constraint-layout:1.0.2'     testcompile 'junit:junit:4.12'     compile 'com.android.support:design:25.3.1'      compile 'com.getbase:floatingactionbutton:1.10.1'  } 

then paste below code fragment:

public class yourfragment extends basefragment  {      @override     public void onattach(context context) {         super.onattach(context);     }      @override     public void oncreate(@nullable bundle savedinstancestate) {         super.oncreate(savedinstancestate);     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          view v = inflater.inflate(r.layout.fragment_home, null, false);         getactivity().settitle(getresources().getstring(r.string.app_name));          v.findviewbyid(r.id.pink_icon).setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {             }         });          floatingactionbutton button = (floatingactionbutton) v.findviewbyid(r.id.setter);         button.setsize(floatingactionbutton.size_mini);         button.setcolornormalresid(r.color.pink);         button.setcolorpressedresid(r.color.pink_pressed);         button.seticon(r.drawable.bubble_in);         button.setstrokevisible(false);          final view actionb = v.findviewbyid(r.id.action_b);          floatingactionbutton actionc = new floatingactionbutton(baseactivity);         actionc.settitle("hide/show action above");         actionc.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 actionb.setvisibility(actionb.getvisibility() == view.gone ? view.visible : view.gone);             }         });          final floatingactionsmenu menumultipleactions = (floatingactionsmenu) v.findviewbyid(r.id.multiple_actions);         menumultipleactions.addbutton(actionc);          final floatingactionbutton removeaction = (floatingactionbutton) v.findviewbyid(r.id.button_remove);         removeaction.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 ((floatingactionsmenu) v.findviewbyid(r.id.multiple_actions_down)).removebutton(removeaction);             }         });          shapedrawable drawable = new shapedrawable(new ovalshape());         drawable.getpaint().setcolor(getresources().getcolor(r.color.white));         ((floatingactionbutton) v.findviewbyid(r.id.setter_drawable)).seticondrawable(drawable);          final floatingactionbutton actiona = (floatingactionbutton) v.findviewbyid(r.id.action_a);         actiona.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 actiona.settitle("action clicked");             }         });          // test fams containing fabs visibility gone not cause crashes         v.findviewbyid(r.id.button_gone).setvisibility(view.gone);          final floatingactionbutton actionenable = (floatingactionbutton) v.findviewbyid(r.id.action_enable);         actionenable.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 menumultipleactions.setenabled(!menumultipleactions.isenabled());             }         });          floatingactionsmenu rightlabels = (floatingactionsmenu) v.findviewbyid(r.id.right_labels);         floatingactionbutton addedonce = new floatingactionbutton(baseactivity);         addedonce.settitle("added once");         rightlabels.addbutton(addedonce);          floatingactionbutton addedtwice = new floatingactionbutton(baseactivity);         addedtwice.settitle("added twice");         rightlabels.addbutton(addedtwice);         rightlabels.removebutton(addedtwice);         rightlabels.addbutton(addedtwice);           return v;      }      @override     public void onviewcreated(view view, bundle savedinstancestate) {         super.onviewcreated(view, savedinstancestate);     }  } 

basefragment should be:

public class basefragment extends fragment implements view.onclicklistener  {     protected baseactivity baseactivity;      @override     public void onattach(context context) {         super.onattach(context);         baseactivity = (baseactivity) context; baseactivity.getapplication();      }      @override     public void ondetach() {         baseactivity = null;          super.ondetach();     } 

and example of your_layout.xml is:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:fab="http://schemas.android.com/apk/res-auto"     android:background="@color/background"     android:layout_width="match_parent"     android:layout_height="match_parent">      <com.getbase.floatingactionbutton.floatingactionbutton         android:id="@+id/pink_icon"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         fab:fab_icon="@drawable/facebook"         fab:fab_colornormal="@color/colorprimarydark"         fab:fab_colorpressed="@color/colorprimary"         android:layout_alignparentbottom="true"         android:layout_centerhorizontal="true"         android:layout_marginbottom="16dp"/>      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_above="@id/pink_icon"         android:text="text below button"         android:layout_centerhorizontal="true"         android:layout_marginbottom="48dp"/>      <com.getbase.floatingactionbutton.addfloatingactionbutton         android:id="@+id/semi_transparent"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_above="@id/pink_icon"         fab:fab_plusiconcolor="@color/white"         fab:fab_colornormal="@color/blue_semi_transparent"         fab:fab_colorpressed="@color/blue_semi_transparent_pressed"         android:layout_centerhorizontal="true"         android:layout_marginbottom="16dp"/>      <com.getbase.floatingactionbutton.floatingactionbutton         android:id="@+id/setter"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_above="@id/semi_transparent"         android:layout_centerhorizontal="true"         android:layout_marginbottom="16dp"/>      <com.getbase.floatingactionbutton.addfloatingactionbutton         android:id="@+id/normal_plus"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         fab:fab_plusiconcolor="@color/half_black"         fab:fab_colornormal="@color/white"         fab:fab_colorpressed="@color/white_pressed"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_marginbottom="16dp"         android:layout_marginleft="16dp"         android:layout_marginstart="16dp"/>      <com.getbase.floatingactionbutton.floatingactionsmenu         android:id="@+id/right_labels"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_above="@id/normal_plus"         android:layout_marginleft="16dp"         android:layout_marginstart="16dp"         fab:fab_addbuttoncolornormal="@color/white"         fab:fab_addbuttoncolorpressed="@color/white_pressed"         fab:fab_addbuttonplusiconcolor="@color/half_black"         fab:fab_addbuttonsize="mini"         fab:fab_labelsposition="right">          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_title="label on right"             fab:fab_colorpressed="@color/white_pressed"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_size="mini"             fab:fab_title="another 1 on right"             fab:fab_colorpressed="@color/white_pressed"/>      </com.getbase.floatingactionbutton.floatingactionsmenu>      <com.getbase.floatingactionbutton.floatingactionsmenu         android:id="@+id/multiple_actions"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_alignparentright="true"         android:layout_alignparentend="true"         fab:fab_addbuttoncolornormal="@color/white"         fab:fab_addbuttoncolorpressed="@color/white_pressed"         fab:fab_addbuttonplusiconcolor="@color/half_black"         android:layout_marginbottom="16dp"         android:layout_marginright="16dp"         android:layout_marginend="16dp">          <com.getbase.floatingactionbutton.floatingactionbutton             android:id="@+id/action_a"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_title="action a"             fab:fab_colorpressed="@color/white_pressed"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:id="@+id/action_b"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_title="action long name won\'t fit on screen"             fab:fab_colorpressed="@color/white_pressed"/>      </com.getbase.floatingactionbutton.floatingactionsmenu>      <com.getbase.floatingactionbutton.floatingactionsmenu         android:id="@+id/multiple_actions_down"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentright="true"         android:layout_alignparentend="true"         android:layout_alignparenttop="true"         fab:fab_addbuttoncolornormal="@color/white"         fab:fab_addbuttoncolorpressed="@color/white_pressed"         fab:fab_addbuttonsize="mini"         fab:fab_addbuttonplusiconcolor="@color/half_black"         fab:fab_expanddirection="down"         android:layout_margintop="16dp"         android:layout_marginright="16dp"         android:layout_marginend="16dp">          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"             fab:fab_size="mini"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:id="@+id/button_remove"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"             fab:fab_title="click remove"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:id="@+id/button_gone"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:id="@+id/action_enable"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_title="set bottom menu enabled/disabled"             fab:fab_colorpressed="@color/white_pressed"/>      </com.getbase.floatingactionbutton.floatingactionsmenu>      <com.getbase.floatingactionbutton.floatingactionsmenu         android:id="@+id/multiple_actions_left"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_toleftof="@+id/multiple_actions_down"         android:layout_tostartof="@+id/multiple_actions_down"         android:layout_alignparenttop="true"         fab:fab_addbuttoncolornormal="@color/white"         fab:fab_addbuttoncolorpressed="@color/white_pressed"         fab:fab_addbuttonsize="mini"         fab:fab_addbuttonplusiconcolor="@color/half_black"         fab:fab_addbuttonstrokevisible="false"         fab:fab_expanddirection="left"         android:layout_margintop="16dp"         android:layout_marginright="16dp"         android:layout_marginend="16dp">          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"             fab:fab_size="mini"/>          <com.getbase.floatingactionbutton.floatingactionbutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:visibility="gone"             fab:fab_colornormal="@color/white"             fab:fab_colorpressed="@color/white_pressed"             fab:fab_size="mini"/>      </com.getbase.floatingactionbutton.floatingactionsmenu>      <com.getbase.floatingactionbutton.floatingactionbutton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/setter_drawable"         android:layout_above="@id/setter"         android:layout_centerhorizontal="true"/> </relativelayout> 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -