Skip to content
Open
Show file tree
Hide file tree
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 @@ -14,7 +14,6 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -28,6 +27,8 @@
import java.util.ArrayList;
import java.util.List;

import androidx.core.content.res.ResourcesCompat;

public class FloatingActionMenu extends ViewGroup {

private static final int ANIMATION_DURATION = 300;
Expand Down Expand Up @@ -165,10 +166,13 @@ private void init(Context context, AttributeSet attrs) {
mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
int customFont = attr.getResourceId(
R.styleable.FloatingActionMenu_menu_labels_customFont,
0
);
try {
if (!TextUtils.isEmpty(customFont)) {
mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
if (customFont != 0) {
mCustomTypefaceFromFont = ResourcesCompat.getFont(context, customFont);
}
} catch (RuntimeException ex) {
throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
Expand Down Expand Up @@ -985,7 +989,7 @@ public void addMenuButton(FloatingActionButton fab, int index) {

public void removeAllMenuButtons() {
close(true);

List<FloatingActionButton> viewsToRemove = new ArrayList<>();
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<enum name="mini" value="1" />
</attr>
<attr name="menu_labels_style" format="reference" />
<attr name="menu_labels_customFont" format="string" />
<attr name="menu_labels_customFont" format="reference" />
<attr name="menu_shadowColor" format="color" />
<attr name="menu_shadowRadius" format="dimension" />
<attr name="menu_shadowXOffset" format="dimension" />
Expand All @@ -84,4 +84,4 @@
<attr name="menu_fab_hide_animation" format="reference" />
</declare-styleable>

</resources>
</resources>
Binary file added sample/src/main/res/font/nunito_sans_regular.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion sample/src/main/res/layout/menus_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
fab:menu_labels_hideAnimation="@anim/jump_to_down"
fab:menu_animationDelayPerItem="0"
fab:menu_shadowColor="#444"
fab:menu_labels_customFont="@font/nunito_sans_regular"
fab:menu_colorNormal="#FFB805"
fab:menu_colorPressed="#F2AB00"
fab:menu_colorRipple="#D99200">
Expand Down Expand Up @@ -285,4 +286,4 @@

</com.github.clans.fab.FloatingActionMenu>

</RelativeLayout>
</RelativeLayout>