Comments (25)
I implemented it like this along with the listener:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.fragmentLayout">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/root_layout"/>
</android.support.v4.widget.SwipeRefreshLayout>
<View
android:id="@+id/shadowView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/Transparentish_White" />
<LinearLayout
android:orientation="vertical"
android:layout_gravity="bottom|end"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/action_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_addButtonColorNormal="@color/holo_blue_dark"
fab:fab_addButtonColorPressed="@color/white_pressed"
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_new_task"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_icon="@drawable/ic_action_tasks"
fab:fab_size="mini"
fab:fab_title="New Task"
fab:fab_colorPressed="@color/white_pressed" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_new_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_icon="@drawable/ic_action_lists"
fab:fab_size="mini"
fab:fab_title="New List"
fab:fab_colorPressed="@color/white_pressed" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_new_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_icon="@drawable/ic_action_notes"
fab:fab_size="mini"
fab:fab_title="New Note"
fab:fab_colorPressed="@color/white_pressed" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</LinearLayout>
</FrameLayout>
And to achieve the Inbox style background shadow, I am changing the visibility of shadowView. However it'll not overlap on the actionbar/toolbar in your activity.
from android-floating-action-button.
We can override the onBackpressed method.
@ Override
public void onBackPressed()
{
if (fabMenu.isExpanded())
{
fabMenu.collapse();
}
else
{
super.onBackPressed();
}
}
from android-floating-action-button.
also if menu is opend, when i click outside of the floating menu i should close. Is it possible?
from android-floating-action-button.
It's currently not supported, but it would definitely be a nice addition.
from android-floating-action-button.
I thought a bit more about this and I think it should be handled by another View + FloatingActionsMenu onExpand/onCollapse listeners. I'd need to add this to the sample application.
from android-floating-action-button.
Yup, that's exactly what I had in mind. Any ideas how to make the menu collapse on user pressing back button?
from android-floating-action-button.
The problem with this approach is that the Activity have to know about the FAM. I'll try to figure something out using Fragments' back stack, but IIRC there were some issues with backstack and nested fragments :(
from android-floating-action-button.
Have you tried public boolean onKeyDown(int keyCode, KeyEvent event)
along with the current state of the button?
Say,
boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode == KeyEvent.KEYCODE_BACK && mExpanded)
collapse();
}
from android-floating-action-button.
Is it possible to add an onExpand/onCollapse listener? I would like to use this to blank out the background as in the Inbox app but am unsure if that is supported or how to do this.
from android-floating-action-button.
@damianhinch it's already implemented in fa4824b, available in since version 1.5.0.
from android-floating-action-button.
@chalup Oh wow sorry I was using an older version mistakenly. Thank you very much!
from android-floating-action-button.
Yep. +1 for this one.
It sometimes hard to hit smaller button.
from android-floating-action-button.
What if you had a blank fragment a with transport white background what you inflated between the fab, and the all other ui elements when the menu is opened, and dismiss on collapse. Then back would dismiss it like any fragment in the stack, and you could set an on click to tell the fragment to collapse the menu. Maybe even bake it into the menu fab view?
from android-floating-action-button.
I'd probably put it into separate helper class implementing FAM listener and Fragment back stack listener, but yeah, that's exactly what I had in mind few comments above.
from android-floating-action-button.
It can be implemented with the help of FloatingActionsMenu.OnFloatingActionsMenuUpdateListener()
, but the problem i'm facing is, when i use this Listener it spoils the nice flow of animation in the floating buttons, any workaround to make the animation fluid....
from android-floating-action-button.
I also tried implementing it myself using OnFloatingActionsMenuUpdateListener callbacks but as above, adding another animation there ruins floating menu animation :(
from android-floating-action-button.
For anyone interested, I implemented this on my fork of this project. Have a look at commits wjwarren@d72b15b, wjwarren@d72b15b, wjwarren@714fff6 and wjwarren@3bf1166 in particular.
from android-floating-action-button.
Thanks for the 1.7 chalup. Would love to see background in next release. (Fingers crossed)
from android-floating-action-button.
@DineshAnandan I am not sure whether its the right solution but i added a GestureDetector on listview and on onFling method was able to close.
from android-floating-action-button.
We have implemented this, However key is the responsibility should lie outside the FAB menu. That feature is clearly not FAB menu's
from android-floating-action-button.
@manjunathc23 I agree, but I also think this is a very common request/use case, so it should be implemented in the sample application.
from android-floating-action-button.
Note to self: take a look at #111 when implementing this stuff.
from android-floating-action-button.
Another note to self: #150
from android-floating-action-button.
I have added a tutorial explaining how you can implement background shadow with current library.
http://www.rishabhsinghal.in/implement-floating-action-button-similar-to-inbox-by-gmail-or-evernote/
from android-floating-action-button.
if you are using a RelativeLayout i can help with a trick to work for you ;
you can set a textview above all your objects before the floating action button
after that you can set your textview to show when your button click (in default it's visibility is gone)
and you can give your textview any color that you want to see it as a dim object when you click the btn (and textview visibility should be visible)
or you can use link below
https://github.com/Clans/FloatingActionButton
from android-floating-action-button.
Related Issues (20)
- Bottom app bar
- How to expand on longClick?? HOT 2
- how to close FloatingActionMenu when Click on Fab button on FabMenu? HOT 1
- add border width border color
- Update Request HOT 5
- Sample code for using library HOT 1
- Drawable **** has unresolved theme attributes
- XML files don't work HOT 2
- Layout overlaping the fab title. Can anyone help me with this. HOT 1
- Can't add icon to the main fab icon button
- How do I change the size other than normal , mini HOT 1
- How to change color of Floating Action Menu on Normal State Programatically ? HOT 1
- support HOT 1
- How to onclick on Menu button? HOT 1
- Center in layout HOT 1
- Expand Direction to left
- feature requirment HOT 1
- AndroidX HOT 1
- Error inflating class com.getbase.floatingactionbutton.FloatingActionsMenu
- Widget from web
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-floating-action-button.