-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set button colors in java does not work #11
Comments
You can set buttons colors only in constructors. <com.ramotion.circlemenu.CircleMenuView
...
app:button_colors="@array/colors"
app:button_icons="@array/icons"/> or in constructor: final ArrayList<Integer> icons = new ArrayList<>();
final ArrayList<Integer> colors = new ArrayList<>();
final Random rnd = new Random();
final int bCount = 6;
for (int i = 0; i < bCount; i++) {
icons.add(android.R.drawable.ic_dialog_email);
colors.add(Color.rgb(rnd.nextInt(255), rnd.nextInt(255), rnd.nextInt(255)));
}
final CircleMenuView menu = new CircleMenuView(this, icons, colors);
final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
menu.setLayoutParams(lp);
final FrameLayout fl = findViewById(R.id.frame_layout);
fl.addView(menu); |
Thanks and I got the reason: the colors array element should be color Integer instead of colorRes int, |
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And I found in CricleMenuView.class, line 240 within the method ' initButtons(...)'
button.setBackgroundTintList(ColorStateList.valueOf(((Integer)colors.get(i)).intValue()));
Should it be simply button.setBackgroundColor??
The text was updated successfully, but these errors were encountered: