简体   繁体   中英

Shadow problem Floating Action Button (api = 19)

I had a problem with FAB shadow on API <= 19. I used compatElevation= 0f and shadow disappeared. But it appears again during onClick and looks strange:

在此处输入图片说明

XML code:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/RateBtn"
    android:layout_width="@dimen/backet_Btn_size"
    android:layout_height="@dimen/backet_Btn_size"
    android:elevation="0dp"
    app:elevation="0dp"

    android:clickable="true"
    android:focusable="true"


    android:src="@drawable/star_rate2"
    app:backgroundTint="@color/w"


    app:layout_constraintEnd_toEndOf="@+id/langBtn2"
    app:layout_constraintStart_toStartOf="@+id/langBtn2"
    app:layout_constraintTop_toTopOf="@+id/SettingsBtn"

    app:rippleColor="@color/grey_700" />

Code:

var fb = view?.findViewById(R.id.RateBtn) as FloatingActionButton
val lp =it.layoutParams

            if (lp !=null){
                lp.width= size_fb
                lp.height=size_fb
                it.customSize=size_fb
                it.layoutParams= lp
            }

I think there is some problem when I try to change FAB size programmatically. When I set size in xml, everything is ok

use this code

android:elevation="0dp" 
app:elevation="0dp"

通过添加来替代FAB的默认高程

android:elevation="0dp"

Java

setStateListAnimator(null);

XML

android:stateListAnimator="@null"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM