material design - Android float button and background overlay -


i have searched not found tutorial or library on how float button background 1 below used in skype.

i followed tutorials using these tutorials making floatbutton.

https://github.com/codepath/android_guides/wiki/floating-action-buttons , https://www.bignerdranch.com/blog/floating-action-buttons-in-android-l/ , https://github.com/codepath/android_guides/wiki/design-support-library

edited please read !

according @simon, able use https://github.com/futuresimple/android-floating-action-button library achieve float button layout. stuck making background dim because cannot set relative layout background color inside library functions.

see working java code below floatbutton, have stripped out other buttons leaving skype alike.

public class floatbuttonactivity extends activity {      relativelayout brl;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_float_button);          //final view actionb = findviewbyid(r.id.action_b);          shapedrawable drawable = new shapedrawable(new ovalshape());         drawable.getpaint().setcolor(getresources().getcolor(r.color.white));           /* button 3 */         final floatingactionbutton actiona = (floatingactionbutton) findviewbyid(r.id.action_a);         actiona.setonclicklistener(new onclicklistener() {             @override             public void onclick(view view) {                 toast.maketext(floatbuttonactivity.this, "clicked on button 3", toast.length_long).show();               }         });          /* button 2 */         final floatingactionbutton actionb = (floatingactionbutton) findviewbyid(r.id.action_b);         actionb.setonclicklistener(new onclicklistener() {             @override             public void onclick(view view) {                 toast.maketext(floatbuttonactivity.this, "clicked on button 2", toast.length_long).show();             }         });           /* button 1 */         floatingactionbutton actionc = new floatingactionbutton(getbasecontext());         actionc.settitle("button 1");         actionc.setonclicklistener(new onclicklistener() {             @override             public void onclick(view v) {                 toast.maketext(floatbuttonactivity.this, "clicked on button 1", toast.length_long).show();             }         });          final floatingactionsmenu menumultipleactions = (floatingactionsmenu) findviewbyid(r.id.multiple_actions);         menumultipleactions.addbutton(actionc);      }  } 

this xml layout below

<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">  <relativelayout     android:id="@+id/floatbutton_layout"     android:layout_width="match_parent"     android:layout_height="match_parent">      <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"         fab:fab_labelstyle="@style/menu_labels_style"         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="button 3"             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="button 2"             fab:fab_colorpressed="@color/white_pressed"/>      </com.getbase.floatingactionbutton.floatingactionsmenu>   </relativelayout>  </relativelayout> 

the problem:

there floatingactionsmenu actions class has onclicklistener set initialize toggle() of button. i doesn't allow me set background color in class, because not activity relative layout. please how can ?

maddbutton.setonclicklistener(new onclicklistener() {       @override       public void onclick(view v) {         toggle(); //this calls other float buttons         log.d("msg: ", "in floatingactionsmenu class");       }     }); 

but want acheive being done in skype's app

i hoping step step guide on how can achieve being done below.

enter image description here

so there libraries available this, 1 such library here want do: https://github.com/futuresimple/android-floating-action-button

however, if want old fashion way, can achieve following steps below:

  1. you can create fab button onclicklistener set on it. once user clicks on fab, screen dim. can getting handler on window through windowmanager class , setting flag flag_dim_behind (windowmanager.layoutparams.flag_dim_behind). code is:

        windowmanager wm = (windowmanager) getactivity().getsystemservice(context.window_service);          windowmanager.layoutparams p = (windowmanager.layoutparams) parent.getlayoutparams();          p.flags = windowmanager.layoutparams.flag_dim_behind;          p.dimamount = 0.4f;          wm.updateviewlayout(parent, p);

  1. you need animate in other fab animating translatey of each icon "fly" upwards click main fab.

  2. you can set onclicklisteners each of new fabs appears on screen have logic when user clicks on them.

this might bit of work prepared research if going old fashion way - use library instead, lot less thinking.

there other guides have more information regarding fab: https://guides.codepath.com/android/floating-action-buttons


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -