-
-
Save Jogan/9def6110edf3247825c9 to your computer and use it in GitHub Desktop.
FloatingActionButton fabButton = new FloatingActionButton.Builder(this) | |
.withDrawable(getResources().getDrawable(R.drawable.ic_action_add)) | |
.withButtonColor(Color.WHITE) | |
.withGravity(Gravity.BOTTOM | Gravity.RIGHT) | |
.withMargins(0, 0, 16, 16) | |
.create(); |
how to hide the button when we don't need it? i can't call it from other activity
Upon adding a FAB using your technique I see a thin translucent ring around the actual image. I tried removing the margins and shadowlayer but it didn't work. Could you suggest how this can be removed?
how can i set an OnClickListener?
Hey i import these code in my sample project but it didn't work on Pre-Lollipop device, Please tell me how i able to see these button on devices below Lollipop...?
Please reply me ASAP
@MatBenetti the same way you would set an OnClickListener on any other view. fabButton.setOnClickListener
I got the button working. How do you add functionalities like adding things that will appear once clicked?
fabButton.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, tabs.class);
startActivity(i);
}
});
i'mm having a problem with FAB overlapping my toolbar and its items
Hi! How i can add this fab button in layout/activity_simple.xml file?
Very nice and easy to use especially in Eclipse.
Where is the location to put this code.. please help m just a novice...
@shahbaz-man how I can change the color dynamically
This code is awsom , simple and helping.. thanks @Jogan ,
Just need how to add icon , my fab is simple white .
builder cannot be resolved
@Jogan, you are the boss!!! thanks so much, so easy to use and light weight. @faisal find below a code snip that haddles ur request.
FloatingActionButton read = new FloatingActionButton.Builder(this)
.withDrawable(getResources().getDrawable(R.drawable.ic_read))
.withButtonColor(Color.YELLOW)
.withGravity(Gravity.BOTTOM | Gravity.RIGHT)
.withMargins(0, 0, 16, 145).create();
USE THE DESIGN SUPPORT LIBRARY - NOT THIS ANYMORE
Too good and simple code thanks a lot..
Nice code, question how can I bring up the menu.xml on onClick?
how to start action button when i click
awsome bosss !!!
how to add another button after clicking on this button
i need to add more button.
Thank you so much for this code.. @Jogan
Your code is very much helpful for us. Thanks 👍
thank you from mw. it's very helpful cause i need to create app project mobile offline.
Hey, thanks for this, I improved this a little bit by adding a character, settings it's size and color, and also xml support and programmatically adding it to a custom layout. Code:
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
public class FloatingActionButton extends View {
}
And in attrs.xml:
http://pastebin.com/TP5JuZQk
Enjoy!