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

border is disappear when setting border programmatically #399

Closed
taehee28 opened this issue Oct 14, 2020 · 4 comments
Closed

border is disappear when setting border programmatically #399

taehee28 opened this issue Oct 14, 2020 · 4 comments

Comments

@taehee28
Copy link

taehee28 commented Oct 14, 2020

Hi! First, thanks for this useful library.

I have a small problem of using it, however.
I used these setBorderWidth() and setBorderColor() method in code for changing border setting in runtime.
But, in actual running time, border was just disappear when called those method.
Why it happens??

Or, is there any good way to change border when CircleImageView clicked to use selector or something?

Waiting for answer

@hdodenhof
Copy link
Owner

Hi @theeeeeee,

what you are trying to do should work. Can you post the code you are using so I can have a look?

For another approach to implement a selector have a look at #153 (comment) - maybe you can adapt that to your needs.

@taehee28
Copy link
Author

Thanks for answer!

I'll refer to the link you attached

Here's my code

public void onClick(View v) {
// It called CircleImageView clicked

    ...    

    if(!v.isSelected) {
        petProflView.setBorderColor(0xFFCB33);
        petProflView.setBorderWidth(convertToPX(2));
    }

    ...
    
}

...

// Is that right that setBorderWidth()'s int parameter means PX? So, I made converting DP to PX method
private int convertToPX(int dp) {
    return (int)(dp * mDensity + 0.5);
}

CircleImageView's border is already set in xml

CircleImageView had border when Activity created, but it clicked and codes are worked and then border is disappear
Is there any mistake in my code?

@hdodenhof
Copy link
Owner

setBorderColor expects a ColorInt - try this: petProflView.setBorderColor(Color.parseColor("#FFCB33")).

You are correct about setBorderWith - it expects PX.

@taehee28
Copy link
Author

Wow... it works perfectly......
Thanks a lot about your answer!!!!

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