Parameterize FAB's maxImageSize.

PiperOrigin-RevId: 168774497
This commit is contained in:
markwei 2017-09-14 20:46:20 -04:00 committed by Miguel Yanez Barreto
parent 40e788f9fd
commit a53014baeb
3 changed files with 4 additions and 2 deletions

View File

@ -81,6 +81,8 @@
<attr name="borderWidth" format="dimension"/>
<!-- Enable compat padding. -->
<attr name="useCompatPadding" format="boolean"/>
<!-- Maximum icon image size. -->
<attr name="maxImageSize" format="dimension"/>
</declare-styleable>
<declare-styleable name="FloatingActionButton_Behavior_Layout">

View File

@ -24,6 +24,7 @@
<item name="pressedTranslationZ">@dimen/design_fab_translation_z_pressed</item>
<item name="rippleColor">?attr/colorControlHighlight</item>
<item name="borderWidth">@dimen/design_fab_border_width</item>
<item name="maxImageSize">@dimen/design_fab_image_size</item>
</style>
<style name="Widget.Design.ScrimInsetsFrameLayout" parent="">

View File

@ -177,6 +177,7 @@ public class FloatingActionButton extends VisibilityAwareImageButton
final float pressedTranslationZ =
a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
mMaxImageSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_maxImageSize, 0);
a.recycle();
mImageHelper = new AppCompatImageHelper(this);
@ -184,8 +185,6 @@ public class FloatingActionButton extends VisibilityAwareImageButton
expandableWidgetHelper = new ExpandableWidgetHelper(this);
mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);
getImpl()
.setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth);
getImpl().setElevation(elevation);