Android FAB背景色在片段中不改变,但在活性中改变?
我以前在我的活动中有这个fab,它工作得很好,但现在我已经将代码从活动转换为片段。现在我有3个晶圆厂在我的布局,我不能改变背景色或其中任何一个。这是我的密码。我做错什么了还是出了什么错?如果有任何帮助,我们将不胜感激 另外,我的fab按钮的颜色是默认的浅绿色,甚至不是我的应用程序的强调色,我可以在布局编辑器中看到反映的更改,但在我的设备上看不到Android FAB背景色在片段中不改变,但在活性中改变?,android,user-interface,floating-action-button,Android,User Interface,Floating Action Button,我以前在我的活动中有这个fab,它工作得很好,但现在我已经将代码从活动转换为片段。现在我有3个晶圆厂在我的布局,我不能改变背景色或其中任何一个。这是我的密码。我做错什么了还是出了什么错?如果有任何帮助,我们将不胜感激 另外,我的fab按钮的颜色是默认的浅绿色,甚至不是我的应用程序的强调色,我可以在布局编辑器中看到反映的更改,但在我的设备上看不到 <com.google.android.material.floatingactionbutton.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_change_map_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:backgroundTint="@color/color_accent"
android:onClick="@{(v) -> viewModel.onClick(v)}"
android:src="@drawable/ic_change_map_display_type"
android:visibility="@{viewModel.routeInfoViewModel.routeInfoViewEnabledLive ? View.GONE : View.VISIBLE}"
app:borderWidth="0dp"
app:fabSize="mini"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/card_gps_error"
app:rippleColor="@color/color_accent" />
对于
FloatingActionButtons
的backgroundTint
属性,您应该使用app:
命名空间
但是你知道为什么android:backgroundTint在“活动”和“片段”中起作用吗?我必须使用“材料组件”参考?
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_change_map_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
app:backgroundTint="@color/color_accent"
...
/>