我在代码中使用了 IconButton
。我使用了不同颜色的可绘制对象。当我运行代码时,它显示为黑色物件。这里出了什么问题?
IconButton(
onClick = { }
) {
Icon(
painter = painterResource(R.drawable.ic_menu),
contentDescription = null,
)
}
实际输出
期望的输出
我在这里分享我的可绘制文件
ic_menu.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="4dp"
android:viewportWidth="20"
android:viewportHeight="4">
<path
android:fillColor="@color/aqua"
android:fillType="evenOdd"
android:pathData="M2,2m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="@color/aqua"
android:fillType="evenOdd"
android:pathData="M10,2m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="@color/aqua"
android:fillType="evenOdd"
android:pathData="M18,2m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
</vector>
Icon
函数的tint
参数? - Thracian