我正在创建一个Android应用程序,我正在使用AndroidX库和Material设计主题.我的应用主题styles.xml是:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我从库中有以下FAB按钮:
<com.leinardi.android.speeddial.SpeedDialView
android:id="@+id/work_log_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:layout_behavior="@string/speeddial_scrolling_view_snackbar_behavior"
app:sdMainFabClosedSrc="@drawable/ic_add_white_24dp"
app:sdOverlayLayout="@id/overlay" />
Run Code Online (Sandbox Code Playgroud)
并尝试了默认的FAB:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_add_white_24dp"
android:layout_margin="16dp" />
Run Code Online (Sandbox Code Playgroud)
没有图标的颜色(矢量可绘制),FAB内的图标(来自库和默认图标)总是黑色.我已经将问题缩小到材料设计主题,因为使用旧的Theme.AppCompat.Light.DarkActionBar而不是新Theme.MaterialComponents.Light.DarkActionBar的FAB内的图标获得原始矢量drawable的颜色.
有谁知道为什么会发生这种情况以及如何解决这个问题?
android android-theme material-design floating-action-button androidx
事实上,我搜索的方式是模仿FAB的收件箱.当用户按下红色按钮时,应显示opac视图和菜单.由于图像更有意义,请参见下图

我知道它存在这个很棒的库(https://github.com/futuresimple/android-floating-action-button),通过这个库,我可以显示浮动动作菜单.但我的问题是显示白色背景(不透明度).我没有找到解决问题的解决方案......
Thx提前