Skip to content

Getting to work backgroundDrawable in JAVA #1016

Answered by cortinico
ankandrew asked this question in Q&A
Discussion options

You must be logged in to vote

What you're doing is correct. However, backgroundDrawable has priority over the other background:

when {
bgDrawable != 0 -> {
mainLayout?.setBackgroundResource(bgDrawable)
}
defaultBackgroundColorRes != 0 -> {
mainLayout?.setBackgroundColor(ContextCompat.getColor(requireContext(), defaultBackgroundColorRes))
}
else -> {
@Suppress("DEPRECATION")
mainLayout?.setBackgroundColor(defaultBackgroundColor)
}
}

If you wish me to investigate further, you need to provide more details (like a reproducer, which versions of AppI…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ankandrew
Comment options

@ankandrew
Comment options

@cortinico
Comment options

@ankandrew
Comment options

Answer selected by ankandrew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants