Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating Action button Shadow issue

I am trying to add text in floating button.

<FrameLayout
        android:id="@+id/gallery_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="15dp"
        android:visibility="invisible">

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/floating_gallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/image_icon"
            app:backgroundTint="@color/white"
            android:layout_marginBottom="10dp"
            app:elevation="6dp"
            app:pressedTranslationZ="12dp" />

        <com.mobile.widget.CircularTextView
            android:id="@+id/gallery_count_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_gravity="end"
            android:elevation="7dp"
            android:gravity="center"
            android:padding="1dp"
            android:textColor="@color/white" />
    </FrameLayout>

This is working fine. I can show the text of the floating button. The problem in floating button shadow is hided half. In image please note for gallery icon shadow is not showing fully. This is happening because of it is surrounded by the frame layout. Is there any other way to achieve this with the show the shadow too? Please let me any idea to resolve this.

image

like image 595
Vijayadhas Chandrasekaran Avatar asked Dec 09 '25 02:12

Vijayadhas Chandrasekaran


1 Answers

Add android:layout_margin="10dp" inside both FloatingActionButton CircularTextView.

<FrameLayout>

    <FloatingActionButton
        ...
        android:layout_margin="10dp" />

    <CircularTextView
        ...
        android:layout_margin="10dp" />
</FrameLayout>

I tried this on my project it's working.

image here

like image 127
Anjal Saneen Avatar answered Dec 11 '25 14:12

Anjal Saneen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!