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

container_background_color #47

Closed
Ni3Narale opened this issue Mar 20, 2017 · 4 comments
Closed

container_background_color #47

Ni3Narale opened this issue Mar 20, 2017 · 4 comments

Comments

@Ni3Narale
Copy link

want to change container_background_color run time programming used tagView.setBackgroundColor();
but cant change the color. any diffrent way to change dynamic color for this?

@whilu
Copy link
Owner

whilu commented Mar 20, 2017

@Ni3Narale
You mean set the TagContainerLayout's background color? There are two ways to change the background color dynamically:

  1. Before you call mTagContainerLayout.setTags(new ArrayList<String>()), call mTagContainerLayout.setBackgroundColor(Color.BLUE) method;
  2. After call mTagContainerLayout.setBackgroundColor(Color.BLUE) method, call mTagContainerLayout.postInvalidate(), this can work in any place/time.

@Ni3Narale
Copy link
Author

Ni3Narale commented Mar 21, 2017

@whilu
Thanks for prompt reply
while loading tag

      tagView.setBackgroundColor(getResources().getColor(R.color.white));
      tagView.setBorderColor(getResources().getColor(R.color.light_gray));
      tagView.setTagTextColor(getResources().getColor(R.color.blue));
      tagView.setBorderRadius(0.0f);

and setting the tag data and after trying to change color like this

if (isBlack) {
           tagView.setBackgroundColor(getResources().getColor(R.color.dark_gray));
           tagView.postInvalidate();
       } else {
           tagView.setBackgroundColor(getResources().getColor(R.color.white));
           tagView.postInvalidate();
       }

can't help me 

@whilu
Copy link
Owner

whilu commented Mar 21, 2017

@Ni3Narale
I tried your code, no problem. Do you do this in UI thread? Or can you provide some log info?

@Ni3Narale
Copy link
Author

@whilu
Thanks a Lot
this code works for me

new Handler().post(new Runnable() {
            @Override
            public void run() {
                if (isBlack) {
                      tagView.setBackgroundColor(getResources().getColor(R.color.dark_gray));
                    tagView.setTagTextColor(getResources().getColor(R.color.white));
                    tagView.setTagBackgroundColor(getResources().getColor(R.color.dark_gray));
                    tagView.postInvalidate();
                } else {
                      tagView.setBackgroundColor(getResources().getColor(R.color.white));
                    tagView.setTagTextColor(getResources().getColor(R.color.blue));
                    tagView.setTagBackgroundColor(getResources().getColor(R.color.white));
                    tagView.postInvalidate();
                }
            }
        });

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