Comments (20)
There is a similar library that managed to add the ripple effect here:
https://github.com/makovkastar/FloatingActionButton
Perhaps it can be useful?
from android-floating-action-button.
OK, I've found out how to add this, but I'm not sure how to offer the change on Github (fork?), so I will tell you what needs to be done here:
attrs.xml:
add this attribute to "FloatingActionButton":
<attr name="fab_colorRipple" format="color" />
FloatingActionButton.java :
add field:
private int mColorRipple;
inside init() method , add this:
mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple, getColor(android.R.color.white));
and add/change those methods:
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void setBackgroundCompat(Drawable drawable) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
RippleDrawable rippleDrawable = new RippleDrawable(new ColorStateList(new int[][]{{}},
new int[]{mColorRipple}), drawable, null);
setBackground(rippleDrawable);
} else if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN)
setBackground(drawable);
else
setBackgroundDrawable(drawable);
}
public void setColorRipple(int color) {
if (color != mColorRipple) {
mColorRipple = color;
updateBackground();
}
}
public void setColorRippleResId(@ColorRes int colorResId) {
setColorRipple(getColor(colorResId));
}
public int getColorRipple() {
return mColorRipple;
}
It works fine, but I think that the shadow gets a ripple too, and that the inner icon image should have a ripple.
Also, I suggest using elevation when possible, instead of the shadow that's used. Check this link:
https://github.com/makovkastar/FloatingActionButton/blob/master/library/src/main/java/com/melnykov/fab/FloatingActionButton.java
from android-floating-action-button.
+1
from android-floating-action-button.
+1
from android-floating-action-button.
+1
from android-floating-action-button.
+1
from android-floating-action-button.
+1
from android-floating-action-button.
+1, will be very useful
from android-floating-action-button.
+1.
Material without ripples?
from android-floating-action-button.
For those who used what I wrote, has anyone had any issues with it?
I got a very rare issue which might be because of what I did:
#175
from android-floating-action-button.
@AndroidDeveloperLB its not working.
from android-floating-action-button.
@Devendrasingh91 Maybe try one of these solutions (got the tip from: https://plus.google.com/+NickButcher/posts/azEU6s4APbu ) :
1.Wrap the drawable in a RippleDrawable² before setting it on the ImageView:
Drawable image = …
RippleDrawable rippledImage = new RippleDrawable(ColorStateList.valueOf(rippleColor), image, null);
imageView.setImageDrawable(rippledImage);
2.Extend ImageView and add a foreground attribute to it (like FrameLayout has³). See this example⁴ from +Chris Banes of adding it to a LinearLayout. If you do this then make sure you pass through the touch co-ordinates so that the ripple starts from the correct point:
@OverRide
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (foreground != null) {
foreground.setHotspot(x, y);
}
}
from android-floating-action-button.
please simplify a bit more, i am not understanding, where i can write this code. and the co-ordinates.
from android-floating-action-button.
@Devendrasingh91 What to explain more exactly ? What didn't you understand ?
Anyway, I've forked the project just to add this code, here:
https://github.com/AndroidDeveloperLB/android-floating-action-button
I'm sure there are better solutions than what I did.
from android-floating-action-button.
i wanted to make such effect.. like if we click a floatmenubutton than the whole layout should get the effect(in which the parent layout get the ripple effect's color.) than goes to next activity as i have to go on another page. may be this will work on Api21, but what about lower verisons? @AndroidDeveloperLB
from android-floating-action-button.
@Devendrasingh91 I don't understand. Maybe you mean this:
ViewAnimationUtils.createCircularReveal()
example:
https://halfthought.wordpress.com/2014/12/02/reveal-activity-transitions/
from android-floating-action-button.
I use for that this fab: https://github.com/Clans/FloatingActionButton
It has a few more features.
from android-floating-action-button.
@Poeschl Google also added its own, for the new library they've published.
from android-floating-action-button.
any news about this?
from android-floating-action-button.
+1
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.