Harish Kamboj Harish Kamboj - 3 months ago 18
Android Question

Floating Action Button size changed automatically

Solved Thanks to all

but did't get the exact reason because few hours ago it was in its normal state and I did't changed anything in that code so why this thing happen ?

Problem

I don't know why my app's FAB size changed I did't changed FAB size. I tried all things like Rebuild project,clean project etc. First I was thinking its an Android studio's bug and Try to search on web but did't get any thing so, I reinstalled android studio but that does't help me. Therefore asking This question.

here is the xml code for Floating Action Button

<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="@android:drawable/ic_input_add"
android:id="@+id/fab"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="false"
android:layout_margin="16dp"/>


Older Virsion of app

this is an older version of app and i did't change anything in this except icon but that did't effect it.

Latest virsion

this is the latest version of app and as you can see Both screen shots are taken from same mobile. Now compare floating button of both images you will see a difference in size .

This floating button is not only affected, all floating button of my app are become smaller in size. Thanks in advance.

Answer

need to add this line in this code : app:fabSize="normal"

Copy paste the below code and see :)

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:src="@android:drawable/ic_input_add"
    android:id="@+id/fab"
<!-- need to add this line in this code-->
    app:fabSize="normal"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="false"/>
Comments