I am trying to make a profile page in Android. I am using a floating action Button to display user picture.
Initially i want to display a default picture.
My xml code goes like this:
<android.support.design.widget.FloatingActionButton
android:layout_height="100dp"
android:layout_width="100dp"
android:id="@+id/userIcon"
app:fabSize="normal"
android:src="@drawable/male_icon"
app:pressedTranslationZ="12dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|center" />
My question is why there is some extra space around the FAB. Cant i remove that space/padding?
EDITED:
here is my full xml code::
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="@drawable/background"
app:contentScrim="#2678AD"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_scrolling" />
<android.support.design.widget.FloatingActionButton
android:layout_height="100dp"
android:layout_width="100dp"
android:id="@+id/userIcon"
app:fabSize="normal"
android:src="@drawable/male_icon"
app:pressedTranslationZ="12dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|center" />
u might want to change the scaletype attribute to center. Like,
android:scaleType="center"
You can remove the extra padding by allowing your icon to be larger in size. This way you can set the icon to be the size of the floating action button.
app:maxImageSize="40dp"
or whatever size you want to give it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With