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

How do i change the background color of the component #2

Open
nospecs opened this issue Aug 13, 2020 · 1 comment
Open

How do i change the background color of the component #2

nospecs opened this issue Aug 13, 2020 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@nospecs
Copy link

nospecs commented Aug 13, 2020

Hey guys, thanks for this amazing library.
I did this

<com.redmadrobot.acronymavatar.AvatarView
android:id="@+id/user_avatar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:background="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:placeholder="@drawable/ic_logo_rounded" />

The background colour appears but in a square behind the avatar. I need your help.

@nospecs nospecs closed this as completed Aug 13, 2020
@nospecs nospecs reopened this Aug 13, 2020
@Fi5t Fi5t self-assigned this Aug 15, 2020
@Fi5t
Copy link
Contributor

Fi5t commented Aug 17, 2020

Hello @nospecs! Thank you for your interest in this library. You can't set background manually without several dirty workarounds. The main idea of this library is to set background automatically based on some simple calculations:

val acronym = getAcronym(rawText)
val backgroundColor = colors[Math.abs(rawText.hashCode() % colors.size)]

setImageDrawable(AcronymDrawable(acronym, backgroundColor, zoomOut))

But you still can take Acronym Drawable and implement your own Avatar View. It's not so convenient, I know. I can add this feature a bit later, if you want. Let me know.

@Fi5t Fi5t added question Further information is requested and removed need to check labels Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants