Skip to content
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

Closed
davidkhala opened this issue Dec 21, 2017 · 2 comments
Closed

set button colors in java does not work #11

davidkhala opened this issue Dec 21, 2017 · 2 comments

Comments

@davidkhala
Copy link

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??

@dvg4000
Copy link
Contributor

dvg4000 commented Dec 21, 2017

You can set buttons colors only in constructors.
In XML-layout:

 <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);

@davidkhala
Copy link
Author

Thanks and I got the reason: the colors array element should be color Integer instead of colorRes int,
I mixed up them before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants