Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to allow icon to fill entire circle of fab #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class FloatingActionButton extends ImageButton {
private float mShadowOffset;
private int mDrawableSize;
boolean mStrokeVisible;
private boolean mIconFillCircle;

public FloatingActionButton(Context context) {
this(context, null);
Expand Down Expand Up @@ -115,6 +116,13 @@ public void setSize(@FAB_SIZE int size) {
public int getSize() {
return mSize;
}

public void setIconFillCircle(boolean fillCircle){
if(mIconFillCircle != fillCircle) {
mIconFillCircle = fillCircle;
updateBackground();
}
}

public void setIcon(@DrawableRes int icon) {
if (mIcon != icon) {
Expand Down Expand Up @@ -239,7 +247,7 @@ void updateBackground() {
getIconDrawable()
});

int iconOffset = (int) (mCircleSize - getDimension(R.dimen.fab_icon_size)) / 2;
int iconOffset = mIconFillCircle ? 0 : (int) (mCircleSize - getDimension(R.dimen.fab_icon_size)) / 2;

int circleInsetHorizontal = (int) (mShadowRadius);
int circleInsetTop = (int) (mShadowRadius - mShadowOffset);
Expand Down