From eac78d7fe1ccc5aff885ac7052e386b02b2f2b9b Mon Sep 17 00:00:00 2001 From: "sebastien.fleury" Date: Tue, 7 Jul 2015 14:54:54 +0200 Subject: [PATCH] Feature #237 set FloatingMenu background color programmatically --- .../floatingactionbutton/FloatingActionsMenu.java | 10 ++++++++++ .../floatingactionbutton/sample/MainActivity.java | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/getbase/floatingactionbutton/FloatingActionsMenu.java b/library/src/main/java/com/getbase/floatingactionbutton/FloatingActionsMenu.java index b5ae2c20..666f3c18 100644 --- a/library/src/main/java/com/getbase/floatingactionbutton/FloatingActionsMenu.java +++ b/library/src/main/java/com/getbase/floatingactionbutton/FloatingActionsMenu.java @@ -144,6 +144,16 @@ public void draw(Canvas canvas) { } } + public void setColorNormalResId(int resId) { + mAddButtonColorNormal=getColor(resId); + mAddButton.setColorNormal(mAddButtonColorNormal); + } + + public void setColorPressedResId(int resId) { + mAddButtonColorPressed=getColor(resId); + mAddButton.setColorPressed(mAddButtonColorPressed); + } + private void createAddButton(Context context) { mAddButton = new AddFloatingActionButton(context) { @Override diff --git a/sample/src/main/java/com/getbase/floatingactionbutton/sample/MainActivity.java b/sample/src/main/java/com/getbase/floatingactionbutton/sample/MainActivity.java index 4928333b..d572dd03 100644 --- a/sample/src/main/java/com/getbase/floatingactionbutton/sample/MainActivity.java +++ b/sample/src/main/java/com/getbase/floatingactionbutton/sample/MainActivity.java @@ -41,9 +41,10 @@ public void onClick(View v) { actionB.setVisibility(actionB.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); } }); - final FloatingActionsMenu menuMultipleActions = (FloatingActionsMenu) findViewById(R.id.multiple_actions); menuMultipleActions.addButton(actionC); + menuMultipleActions.setColorNormalResId(android.R.color.holo_orange_dark); + menuMultipleActions.setColorPressedResId(android.R.color.holo_orange_light); final FloatingActionButton removeAction = (FloatingActionButton) findViewById(R.id.button_remove); removeAction.setOnClickListener(new OnClickListener() {