https://kotlinlang.org logo
#compose
Title
# compose
r

Rafs

12/03/2020, 11:27 AM
What is the preferred way of loading an icon into a
FloatingActionButton
?
a

allan.conda

12/03/2020, 11:27 AM
* @param content the content of this FAB - this is typically an [Icon].
r

Rafs

12/03/2020, 11:31 AM
I have a drawable xml icon that I want to load but it seems I can't do that with
imageResource()
k

Kshitij Patil

12/03/2020, 11:43 AM
I think you might want to use
vectorResource
for that
r

Rafs

12/03/2020, 11:46 AM
I don't see an overload of
Icon
composable which accepts the
ImageVector
produced from
vectorResource
k

Kshitij Patil

12/03/2020, 11:46 AM
Which compose version are you using?
r

Rafs

12/03/2020, 11:48 AM
alpha08
a

allan.conda

12/03/2020, 11:49 AM
👍 1
k

Kshitij Patil

12/03/2020, 11:49 AM
Check whether the parameter name being changed to
asset
a

André Kindwall

12/03/2020, 1:04 PM
Copy code
FloatingActionButton(
    modifier = modifier
        .padding(FabPadding)
        .align(Alignment.BottomEnd),
    onClick = onClick
) {
    Icon(imageVector = vectorResource(id = R.drawable.ic_add))
}
@allan.conda Why do you wrap ImageVector in a VectorPainter?
a

allan.conda

12/03/2020, 2:24 PM
I don’t, that’s official API
that’s the method you called in your code
a

André Kindwall

12/03/2020, 3:04 PM
Oh 😄