简体   繁体   中英

Can't create round button with FloatingActionButton

When I use FloatingActionButton button it isn't created correctly.

FloatingButton

<android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/fab"
        android:tint="@android:color/white"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:fabSize="mini"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_send_black_24dp"/>

What should I do to display the button correctly ?

You might want to switch to the new material components. Other than that, this is what works for me. Did you enable the appcompat styles for your app?

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@drawable/round_add_white_24" />

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