我正在 android 中使用 FAB,我已經增加了 Src 影像大小以覆寫 FAB,但是現在每當我單擊 FAB 時,漣漪效應都會顯示在影像后面而不是其上方,這不會給人一種點擊 FAB 的感覺

我的FAB代碼
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@ id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:maxImageSize="@dimen/_130sdp"
android:layout_gravity="center|bottom"
android:contentDescription="@string/app_name"
app:srcCompat="@drawable/ic_radial_gradient"
app:backgroundTint="@color/white"
app:elevation="0dp"
app:layout_anchor="@id/bottomAppBar"
app:tint="@null"/>
uj5u.com熱心網友回復:
您可以簡單地使用foregroundfor 您View來實作可點擊效果:它應該是這樣的:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@ id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:maxImageSize="@dimen/_130sdp"
android:layout_gravity="center|bottom"
android:contentDescription="@string/app_name"
app:srcCompat="@drawable/ic_radial_gradient"
app:backgroundTint="@color/white"
app:elevation="0dp"
app:layout_anchor="@id/bottomAppBar"
app:tint="@null"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
/>
我們只需將此行添加到View單擊時即可顯示漣漪效果。
android:foreground="?android:attr/selectableItemBackgroundBorderless"
uj5u.com熱心網友回復:
嘗試將此行添加到您的 XML
android:foreground="?android:attr/selectableItemBackgroundBorderless"
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/346357.html
