makovkastar / floatingactionbutton Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Android floating action button
License: MIT License
[DEPRECATED] Android floating action button
License: MIT License
How to use this eclipse IDE
It would be very nice, if we could use this FAB with a SwipeRefreshLayout. Currently it's buggy for me, if you scroll up the Listview.
It's not a problem of FAB.
Please delete, thx. ;)
Title says it all really. Adding the empty view with the standard list.setEmptyView()
Rendering Problems The following classes could not be instantiated:
- com.orange.ftpworld.floatingactionbutton.FloatingActionButton (Open Class, Show Exception)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details java.lang.ClassNotFoundException: android.graphics.drawable.shapes.OvalShape
when i add the code in my xml , i got this error , i can run in my phone the project but i cant see floating button
After using FloatingActionButton my main layout started looking like the image below. My drawable code is this: http://pastebin.com/LNepQ7rm (I use it as background for a linear layout)
what could be the conflict? My layout should be like the second image
I'm using FloatingActionButton in a different activity, though the only effected activity is the startup activity.
I'm getting
java.lang.ClassNotFoundException: android.graphics.drawable.shapes.OvalShape
exception while editing layout in Android Studio 0.8.11.
Anyone else experiencing this or should we really modify createDrawable
method to add isInEditMode()
modification?
Hi,
I'm using FloatingActionButton library along with a dynamic ListView populated using an ArrayAdapter. My app allows the user to add and remove items from the ListView by tapping on the FAB or swipping to dismiss respectively.
My problem is that if all items on the listview are removed, automatically, the FAB hides making impossible to add a new item to the list.
Is this a bug or is the normal behavior? And if is normal, do you know some workaround?
Thank you!
Is it possible to animate the FAB if its not attached to a listview or gridview?
Mine is on top of a relative layout.
Thanks
By not allowing OnScrollListener to be overridden, and instead only providing OnScrollUp and OnScrollDown, this library is hiding asyncronous data that comes through those methods such as visible/total items and the scroll state with access to a valid view:
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
What about compatibility with snackbars?
Snackbars should not block FAB!
So, FAB should move away when Snackbar is shown.
If i attach two fabs to the same list view only one listens the onScroll so only one hides when scrolling.
Is there a way to attach both of them to onScroll?
Thanks
I'm trying to use circular reveals to show and hide a FAB, with code that looks like this:
ImageButton fab = (ImageButton) findViewById(R.id.fab);
int cx = (fab.getLeft() + fab.getRight()) / 2;
int cy = (fab.getTop() + fab.getBottom()) / 2;
Animator fabAnimator = ViewAnimationUtils.createCircularReveal(fab, cx, cy, (fab.getWidth()/2), 0);
fabAnimator.setDuration(500);
fabAnimator.start();
However, this doesn't seem to work correctly, as the FAB either disappears as soon as the animation starts, or appears as soon as it ends, depending on if I'm trying to hide it or show it. The circular reveal has worked on every other view I've tried it on, so I'm left to believe it must be a problem with the library. Any idea what gives?
Currently when using a list view, I set the onScrollListener(this) and use to be able to determine what to do if I got past a certain point.
If I attach the FAB to the same list view. My onScrollListener implementation never gets called.
I unattached the FAB from the list view and it works like it was suppose to again.
Anyone else noticing this?
When the number of ListView items is at the point where they fill all/most of the screen, but still fit within the screen so no scrolling is yet possible/activated the button covers the bottom list items. Since, one of the main features of this particular FAB library is that the FAB hides when scrolling I would suggest attaching to swipe up/down motions instead of onScrollDown() and onScrollUp().
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library com.melnykov:floatingactionbutton:1.0.1
Thanks.
Example: start an activity and just animate FAB to show up.
Thanks for the great library.
Unfortunately, I get an error when using it on Android 2 devices.
Have you tested it on Android 2 devices?
Here is the stacktrace. If I remove the FAB, the app starts:
E/AndroidRuntime(341): FATAL EXCEPTION: main
E/AndroidRuntime(341): java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
E/AndroidRuntime(341): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
E/AndroidRuntime(341): at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:3696)
E/AndroidRuntime(341): at android.widget.FrameLayout$LayoutParams.(FrameLayout.java:457)
E/AndroidRuntime(341): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:423)
E/AndroidRuntime(341): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:47)
E/AndroidRuntime(341): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:699)
E/AndroidRuntime(341): at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
E/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
E/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
Spent a half hour trying to figure out why the button wasn't moving when scrolling occurred. I had the code to attach the FAB to a recyclerview prior to the adapter being set and it compiled and ran, except for the movement error everything worked. I tried moving it to after the adapter was attached and only then discovered the following:
Currently only LinearLayoutManager is supported for the RecyclerView.
You should probably state this in the Readme file.
I got this exception whenever I got back into my app after the fragment has been destroyed
Class not found when unmarshalling: com.melnykov.fab.FloatingActionButton$SavedState, e: java.lang.ClassNotFoundException: com.melnykov.fab.FloatingActionButton$SavedState
Any idea why this happens?
If you look at many of the Google apps running on Android 5.0, their FABs all have a circular ripple effect when they are touched. The effect is subtle but it looks really nice. It would be great to see the same thing in this library.
I know that Gingerbread is far away, but i would like to use your library for a project which has to be API 10 and up
I think it is just a little fix, something like "if < 10 then no animate on hide"
java.lang.NoSuchMethodError: com.melnykov.fab.FloatingActionButton.animate
at com.melnykov.fab.FloatingActionButton.toggle(FloatingActionButton.java:312)
at com.melnykov.fab.FloatingActionButton.hide(FloatingActionButton.java:286)
at com.melnykov.fab.FloatingActionButton.hide(FloatingActionButton.java:278)
at com.melnykov.fab.FloatingActionButton$FabOnScrollListener.onScrollUp(FloatingActionButton.java:398)
at com.melnykov.fab.ScrollDirectionDetector.onScroll(ScrollDirectionDetector.java:33)
at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:772)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3411)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:2233)
at android.widget.ListView.onTouchEvent(ListView.java:3446)
Thank you!
Your documentation states that you should use a drawable of 24dp as the src attribute. I assume this is 24dp baseline (MDPI), which means XXHDPI would be a 72x72 image. However, your sample uses a 96x96 image in the XXHDPI folder.
Hi,
I would like suggest an enhancement for this library: can you develop a method to call for close or open the floating button (animate from bottom to top and viceversa)? :)
Thanks!
Я попробовал использовать эту чудесную либу вместе с StickyListHeaders.
И так получается, что ваш класс перебивает onScrollListener, который уже выставлен второй либой.
Было бы замечательно, если бы можно было часть переменных и методов повысить до protected, т.к. сейчас мне пришлось скопировать весь код класса ради одного дополнительного метода.
В любом случае спасибо за труд :)
Hey, just wanted to confirm that this library doesn't require any ProGuard configuration? Thank you!
Any chance you can add some standard icons like the plus, minus, check mark, etc?
The z value should be 8dp, looks like it is currently set to 4?
If items of a list view have different height, then animation to show/hide FAB when scrolling isn't smooth sometimes. I think it is due to assumption in getListViewScrollY method that all items have the same height.
In your library the shadow appears all around the button, like it's floating off the page. However, according to http://www.google.com/design/spec/patterns/promoted-actions.html#promoted-actions-floating-action-button the shadow should only appear on the bottom half, like it's a sticker that's half-way peeled off from the page.
The shadow is on south-east but should be only on south based on this: http://www.google.com/design/spec/layout/layout-principles.html#layout-principles-dimensionality.
Thanks!
Using a background color with some alpha (e.g. #99fe0038
) when the shadow attribute value is set to true reveals two circles: one for the floating action button and another inside (cf. image below). The latter is probably caused by the shape of the drawable that is used for creating the shadow.
It would be nice to get a circle without the inner one when a transparent background color is used.
I have also noticed that the image drawable used for the shadow isn't provided for xxxhdpi
.
I think the crash is because of setBackgroundCompat (Build.VERSION_CODES.JELLY_BEAN).
http://stackoverflow.com/a/3549131
I'd love to be able to set the buttons view as text vs an icon, would be great for countdowns etc...
Hi,
Is there anyway I can make this library work in eclipse? I have tried creating a new library project and importing the contents but the recylceview is not imported in eclipse. Please help....
Does this actionbutton can be used on a scrollview??
For now the button doesn't have a shadow. It would be nice to add it.
I'm new to Android development, and I'd like my app to run on 2.3.3 devices, is there any way that the FloatingActionButton could support this?
Thanks!
When compiling I get error:
uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library com.melnykov:floatingactionbutton:1.0.4
Hi,
I'm trying to customize a ScrollDirectionListener of FabRecyclerOnViewScrollListener with keeping show / hide FloatingActionButton.
However, the mFloatingActionButton is private, so I cannot call show() and hide() of mFloatingActionButton in extended FabRecyclerOnViewScrollListener.
Of course, the above behavior can be achieved with below codes.
class MyScrollListener extends FloatingActionButton.FabRecyclerOnViewScrollListener {
private ScrollDirectionListener mListener;
public MyFabRecyclerOnViewScrollListener() {
super();
mListener = getScrollDirectionListener();
setScrollDirectionListener(new ScrollDirectionListener() {
@Override
public void onScrollDown() {
mListener.onScrollDown();
// custom code...
}
@Override
public void onScrollUp() {
mListener.onScrollUp();
// custom code...
}
});
}
}
I think it's redundant.
Could you change the access level of mFloatingActionButton from private to protected?
If you use the button on an API < 11 device, you get an error with the animate() method.
I made a little change that maybe you could include on the next version. I included NineOldAndroids to the gradle dependencies and changed this piece of code:
@Override
public void handleMessage(Message msg) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
animate()
.setInterpolator(mInterpolator)
.setDuration(TRANSLATE_DURATION_MILLIS)
.translationY(mSettledScrollY);
} else {
// Here I have a Frame Layout on my layout, but maybe you could use a generic view or some other approach
FrameLayout fm = (FrameLayout)mListView.getParent();
// fm.getChildAt(1) this is the button
com.nineoldandroids.view.ViewPropertyAnimator.animate(fm.getChildAt(1))
.setInterpolator(mInterpolator)
.setDuration(TRANSLATE_DURATION_MILLIS)
.translationY(mSettledScrollY);
}
}
Hope it helps!
Needs support to attach to a RecyclerView, which wouldn't be much more difficult then the ListView implementation.
Currently I'm using your library by make apps look and feel with material design features but my application support from api level 9, I'm download your project and only change the next lines by enable support for lower api level the change it's
VERSION_NAME=1.0.8
VERSION_CODE=8
GROUP=com.melnykov
ANDROID_BUILD_MIN_SDK_VERSION=9
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.0.2
I'll send a pull request to validate if allow the change :)
I can't seem to figure it out. The way it is setup appears to only attach to ListViews. Is there something I am missing?
Yo. I happened to see that inside the main class there's a boolean mVisible that changes depending on if you've called show() or hide() for the fab. For me it was just that method I needed to use, so I implemented it in the class.
Thought it could be a good enhancement to have in general.
I cloned the repo and trying to open the project in Android Studio 0.9.2
Since this requires gradle build 0.14.1 I made that change, plus I'm also trying to use sdk 4.4.2 (19)
diff --git a/build.gradle b/build.gradle
index b790036..8a5da52 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.12.+'
+ classpath 'com.android.tools.build:gradle:0.14.1+'
}
diff --git a/gradle.properties b/gradle.properties
index 0e3f783..92f1887 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,10 +21,10 @@ VERSION_NAME=1.0.6
VERSION_CODE=7
GROUP=com.melnykov
-ANDROID_BUILD_MIN_SDK_VERSION=14
-ANDROID_BUILD_TARGET_SDK_VERSION=21
-ANDROID_BUILD_SDK_VERSION=21
-ANDROID_BUILD_TOOLS_VERSION=21.0.2
+ANDROID_BUILD_MIN_SDK_VERSION=19
+ANDROID_BUILD_TARGET_SDK_VERSION=19
+ANDROID_BUILD_SDK_VERSION=19
+ANDROID_BUILD_TOOLS_VERSION=21.1.1
Android Studio throws this error while opening the project:
Cause: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
How can I make the action bar and my tab bar hide when the float button hides..
I use a RecyclerView. I don't understand the documentation and I couldn't find examples. Nice library by the way!
It should be very useful to attach the FAB to a scrollview and hide/show it the same way than with a ListView.
Hello,
First of all allow me to thank you. This custom view is amazing :)
I was trying to implement it in my app to check how it works and I encountered an issue.
If I populate the ListView (or GridView in my case), using a LoaderManager, there might be an IndexOutOfBounds exception when calculating scroll Y if the list hasn't finished populating yet.
I tried attaching the view to the GridView in onLoadFinished and that seems to work only if there is a small amount of data to populate.
I'm trying to solve this right now, but if you have any lead, that would be awesome!
And thanks again.
EDIT:
I added a check if (mAdapter.getCount() != 0) in onLoadFinished() before attaching the GridView to the FloatButton.... this way I make sure there is info in the adapter once the attached method gets called.
I hope its stable enough...
the size of the FAB on non lollipop is bigger because of the shadow so changing the margin in xml will not have the same effect and you need to have different dimension for Lollipop
Would love to see someone add a feature to include the progress activity as noted here:
http://www.google.com/design/spec/components/progress-activity.html#progress-activity-types-of-indicators
-By adding the progress to the outer circle of the FAB.
Any thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.