How to remove those dark circular background from floating action button?

[亡魂溺海] 提交于 2020-02-25 04:15:08

问题


I am not able to remove those dark circle background from floating action button. By default it has a circle button with above circular shade. but some how couldnt find a way to remove that shade.

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".VoipActivity"
android:id="@+id/VOIP_username">





<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="179dp"
    android:layout_height="185dp"
    android:layout_gravity="bottom|end"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:backgroundTint="@android:color/transparent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.502"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.844"
    app:rippleColor="?attr/colorBackgroundFloating"
    app:srcCompat="@drawable/preview" />[![enter image description here][1]][1]

回答1:


You can use android:outlineProvider="none".

Also, if you are using FloatingActionButton provided by the Material Components Library you can use a square fab just using the app:shapeAppearanceOverlay attribute.

Something like:

  <com.google.android.material.floatingactionbutton.FloatingActionButton 
          app:srcCompat="@android:drawable/..."
          app:shapeAppearanceOverlay="@style/SquareFabShapeOverlay"
          ../>

And in the style:

      <style name="SquareFabShapeOverlay" parent="ShapeAppearanceOverlay.MaterialComponents.FloatingActionButton">
        <item name="cornerSize">0dp</item>
      </style>



来源:https://stackoverflow.com/questions/58219943/how-to-remove-those-dark-circular-background-from-floating-action-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!