android - Can't remove "shadow" from unelevated transparent FloatingActionButton -
after spending multiple hours researching problem, decided ask instead of wasting more time on such (seemingly) easy task.
i'm trying implement floatingactionbutton transparent background , no broder, show custom icon. know material design discourages it, need way.
the problem face there shadow showing, don't want. since set elevation 0dp don't know how got there , how can remove it.
here code fragment containing fab:
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fragment_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_sample" android:elevation="0dp" android:fitssystemwindows="true"> <android.support.v7.widget.recyclerview android:id="@+id/fragment_grid" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitssystemwindows="true" android:gravity="center" android:padding="10dp" android:stretchmode="columnwidth" android:verticalspacing="25dp"/> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" style="@style/apptheme" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center" android:layout_marginbottom="@dimen/activity_vertical_margin" android:adjustviewbounds="true" android:elevation="0dp" android:fitssystemwindows="true" android:scaletype="fitcenter" app:borderwidth="0dp" app:fabsize="normal" app:layout_anchorgravity="bottom|center" app:layout_behavior="scrollawarefabbehavior" /> </android.support.design.widget.coordinatorlayout>
here apptheme:
<style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/coloraccent</item> <item name="android:fitssystemwindows">true</item> <item name="android:spotshadowalpha">0</item> <item name="android:shadowradius">0</item> <item name="android:ambientshadowalpha">0</item> <item name="selectableitembackgroundborderless">@null</item> </style>
the oncreateview of fragment in set transperancy:
@override public final view oncreateview(final layoutinflater inflater, final viewgroup container, final bundle savedinstancestate) { // initialize variables view view = inflater.inflate(r.layout.fragment_desk, container, false); coordinatorlayout = (coordinatorlayout) view.findviewbyid(r.id.fragment_layout); fab = (floatingactionbutton) coordinatorlayout.findviewbyid(r.id.fab); fab.getbackground().setcolorfilter(color.transparent, porterduff.mode.clear); return view; }
tl;dr: how can remove shadow shown in second picture?
edit: seems, problem linked fab size. set design_fab_size_normal 200 see, does. turns out doesn't affect icon size size of shadow.
here dimens.xml:
<resources xmlns:tools="http://schemas.android.com/tools"> <dimen name="design_fab_image_size" tools:override="true">64dp</dimen> <dimen name="design_fab_size_normal" tools:override="true">200dp</dimen> </resources>
it should be:
app:elevation="0dp"
instead of:
android:elevation="0dp"
you can java code using:
float zeroelevation=0.0f; view.setelevation(zeroelevation);
Comments
Post a Comment