I'm trying to get a `Surface` (actually `<http://a...
# compose
s
I'm trying to get a
Surface
(actually
<http://androidx.tv|androidx.tv>.material3.Surface
but should be the same i think) with a custom bg, either from xml resources, or a ShaderBrush. The problem is that it only takes a list of Colors for the different states (focused, pressed etc). Setting Modifier.paint(painterResource)) doesn't scale up with the Surface's scale indication. Do I have to implement my Layout, or is there an easier way to achieve this?
nevermind, setting .paint on the Surface's child instead of the surface itself fixes this
s
What do you mean by “scale indication”? I haven’t used Modifier.paint before, but it seems like it may be to paint the content itself and not the background of your composable no?
s
oh this might be specific to the TV version of Surface, but it takes a `scale`which internally is used with
Modfiier.indication(..., ScaleIndication)
today i learned 1
s
Btw we’ve had to do exactly this in the past, and this (from here) worked perfectly fine for us, also exactly as you describe, on the child of the surface itself. But we just used
drawWithCache
instead. Does painter do what you expect it to do after all? Was I wrong in my question before about it not painting the background?
s
From
Modifier.paint
javadoc, seems like you are right:
Copy code
Paint the content using painter.
But it works as I expected... 🤔
blob thinking fast 1