java - setOnClickListiner in FloatingActionMenu -
i wondering if there possibility of overriding setonclicklistiner in floatingactionmenu. lastly, found tutorial:
http://www.viralandroid.com/2016/02/android-floating-action-menu-example.html
what need create menu on top of other system icons. want allow user move floatingactionmenu without triggering menu itself. in detail, want move button id material_design_android_floating_action_menu (according tutorial) without triggering menu itself. far have menu on top of system icon, wanted, have no idea how move it. setontouchlistiner doesn't work. assume library (this not android standard lib) has setted kind of listiner material_design_android_floating_action_menu set own allow user move witout triggering whole menu. idea how that?
thanks in advance. :)
materialdesigndialogservice
public class materialdesigndialogservice extends service { private windowmanager windowmanager; windowmanager.layoutparams params; int lastpositionx, lastpositiony; view dialoglayout; private android.widget.relativelayout.layoutparams layoutparams; @override public boolean onunbind(intent intent){ return false; } @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { super.oncreate(); layoutinflater inflater = (layoutinflater) getsystemservice(layout_inflater_service); final view dialoglayout = inflater.inflate(r.layout.material_design_dialogbox, null); settheme(r.style.apptheme); windowmanager = (windowmanager) getsystemservice(window_service); params = new windowmanager.layoutparams( windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.type_phone, windowmanager.layoutparams.flag_not_focusable, pixelformat.translucent); params.gravity = gravity.top | gravity.right; params.x = 0; params.y = 0; windowmanager.addview(dialoglayout,params); dialoglayout.findviewbyid(r.id.material_design_floating_action_menu_item1).setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.e("brawo","floatingactionbutton1"); } }); dialoglayout.findviewbyid(r.id.material_design_floating_action_menu_item2).setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.e("brawo","floatingactionbutton2"); } }); dialoglayout.findviewbyid(r.id.material_design_floating_action_menu_item3).setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.e("brawo","floatingactionbutton3"); } }); try { dialoglayout.findviewbyid(r.id.material_design_android_floating_action_menu).setontouchlistener(new view.ontouchlistener() { private windowmanager.layoutparams paramsf = params; private int initialx; private int initialy; private float initialtouchx; private float initialtouchy; float move_x_axis,move_y_axis; @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_down: log.e("action_down","1"); initialx = paramsf.x; initialy = paramsf.y; initialtouchx = event.getrawx(); initialtouchy = event.getrawy(); break; case motionevent.action_up: log.e("action_up","2"); break; case motionevent.action_move: log.e("action_move","3"); paramsf.x = initialx + (int) (event.getrawx() - initialtouchx); paramsf.y = initialy + (int) (event.getrawy() - initialtouchy); windowmanager.updateviewlayout(dialoglayout, paramsf); move_x_axis = event.getrawx() - initialtouchx; move_y_axis = event.getrawy() - initialtouchy; lastpositionx = paramsf.x; lastpositiony = paramsf.y; break; } return false; } }); } catch (exception e) { // todo: handle exception } } @override public void ondestroy(){ super.ondestroy(); if(dialoglayout!=null) windowmanager.removeview(dialoglayout); } }
Comments
Post a Comment