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 e9c98df..5620dcb 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java @@ -112,11 +112,15 @@ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAtt @TargetApi(Build.VERSION_CODES.LOLLIPOP) public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - init(context, attrs, defStyleAttr); + init(context, attrs, defStyleAttr, defStyleRes); + } + + protected void init(Context context, AttributeSet attrs, int defStyleAttr) { + init(context, attrs, defStyleAttr, 0); } - private void init(Context context, AttributeSet attrs, int defStyleAttr) { - TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0); + protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, defStyleRes); mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, 0xFFDA4336); mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, 0xFFE75043); mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled, 0xFFAAAAAA); diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 0b80e4c..d82e6df 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -120,11 +120,21 @@ public FloatingActionMenu(Context context, AttributeSet attrs) { public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - init(context, attrs); + init(context, attrs, defStyleAttr); } - private void init(Context context, AttributeSet attrs) { - TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0); + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(context, attrs, defStyleAttr, defStyleRes); + } + + protected void init(Context context, AttributeSet attrs, int defStyleAttr) { + init(context, attrs, defStyleAttr, 0); + } + + protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, defStyleAttr, defStyleRes); mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing); mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin); mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);