I am trying to use floatingActionButton and try to...
# compose
a
I am trying to use floatingActionButton and try to add icon which is in a vector.xml. But there is only image and or shape and nothing for vectorImage. Is there any way to do that.
Copy code
Column(modifier = ExpandedHeight, crossAxisAlignment = CrossAxisAlignment.End, mainAxisAlignment = MainAxisAlignment.End ) {
        Column(modifier = Spacing(16.dp)) {
            val icon = +imageResource(R.drawable.add)
            FloatingActionButton(icon = icon, color = Color.Red, elevation = 8.dp)
        }
    }
Also tried using +vectorResource(R.drawable.add) as Image
k
have you seen this? maybe this solves your issue as well 🙂 https://kotlinlang.slack.com/archives/CJLTWPH7S/p1572918696361300
a
DrawVector return type is Unit and FloatingActionButton icon field accepts only image. Hence, DrawVector is not working. Is there is any other possible way to do this ?
k
you can roll your own:
Copy code
FloatingActionButton(
        onClick = onClick,
        color = color,
        elevation = elevation,
        minSize = ExtendedFabHeight) {
            Padding(left = ExtendedFabIconPadding, right = ExtendedFabTextPadding) {
                Row {
                    DrawVector{} 
                    WidthSpacer(width = ExtendedFabIconPadding)
                    Text(text = text, style = textStyle)
                }
            }
        }
    }
n
a
@kloba It is working. But android studio show warning
Variable icon is never used
🤘 1