Floating Action Button with square shape

前端 未结 4 1850
轮回少年
轮回少年 2021-01-05 23:31

When I set a color to my fab, it looks like so:

\"enter

My layout xml:

相关标签:
4条回答
  • 2021-01-05 23:48

    Use this code in your xml

    app:borderWidth="0dp"

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add"
        android:layout_marginRight="20dp"
        app:fabSize="normal"
        android:elevation="@dimen/fab_elevation"
        android:background="#000000"
        app:borderWidth="0dp"
        android:stateListAnimator="@animator/fab_anim"
        android:layout_gravity="center_horizontal"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true" />
    
    0 讨论(0)
  • 2021-01-05 23:56

    Use

    app:backgroundTint="@android:color/holo_green_dark"
    

    (for example) to set color of fab. Result below. Taken from this -tested- code snippet.

    enter image description here

    Also edit : "strange green color" should come from your accent color. That's the color fab takes by default.

    0 讨论(0)
  • 2021-01-05 23:56

    simply setting app:borderWidth="0dp" resolve the issue.

    0 讨论(0)
  • 2021-01-06 00:04

    just add app:borderWidth="0dp"

    0 讨论(0)
提交回复
热议问题