From 2b51a76fa3dc621b94c6a78c220b1d0c396c6d97 Mon Sep 17 00:00:00 2001 From: drobertson Date: Wed, 9 Dec 2015 14:05:19 -0800 Subject: [PATCH 1/2] Customize progress width with XML or java --- .../java/com/github/clans/fab/FloatingActionButton.java | 9 +++++++++ library/src/main/res/values/attrs.xml | 1 + 2 files changed, 10 insertions(+) diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java index ea72dd2..e98384c 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java @@ -135,6 +135,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) { mProgressBackgroundColor = attr.getColor(R.styleable.FloatingActionButton_fab_progress_backgroundColor, 0x4D000000); mProgressMax = attr.getInt(R.styleable.FloatingActionButton_fab_progress_max, mProgressMax); mShowProgressBackground = attr.getBoolean(R.styleable.FloatingActionButton_fab_progress_showBackground, true); + mProgressWidth = attr.getDimensionPixelSize(R.styleable.FloatingActionButton_fab_progress_width, mProgressWidth); if (attr.hasValue(R.styleable.FloatingActionButton_fab_progress)) { mProgress = attr.getInt(R.styleable.FloatingActionButton_fab_progress, 0); @@ -1124,6 +1125,14 @@ public void setElevation(float elevation) { } } + public int getProgressBarWidth() { + return mProgressWidth; + } + + public void setProgressBarWidth(float width) { + mProgressWidth = Util.dpToPx(getContext(), width); + } + /** * Sets the shadow color and radius to mimic the native elevation. * diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 6348758..0eec6e3 100755 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -25,6 +25,7 @@ + From d3f0624eea4cdcc0e646578b460c44952fee4164 Mon Sep 17 00:00:00 2001 From: Daniel Robertson Date: Wed, 9 Dec 2015 14:11:11 -0800 Subject: [PATCH 2/2] Update README.md with fab_progress_width --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e18bc0..f7a054f 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,8 @@ Here are all the **FloatingActionButton**'s xml attributes with their **default app:fab_progress_indeterminate="false" app:fab_progress_max="100" app:fab_progress="0" - app:fab_progress_showBackground="true"/> + app:fab_progress_showBackground="true" + app:fab_progress_width="6dp"/> ``` All of these **FloatingActionButton**'s attributes has their corresponding getters and setters. So you can set them **programmatically**.