android - Unwanted whitespace around Floating Action Button -


what's happening here? looks fab being greedy (left screenshot) , acts when turn on "show layout boundaries" in debug menu (right screenshot).

layout issue , without "show layout boundaries"

activity_main.xml:

  <?xml version="1.0" encoding="utf-8"?>     <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android"         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:fitssystemwindows="true"         tools:context="com.registrationmax.recordbook.mainactivity">          <android.support.design.widget.appbarlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:id="@+id/appbar"             android:theme="@style/apptheme.appbaroverlay">              <android.support.v7.widget.toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 android:background="?attr/colorprimary"                 app:popuptheme="@style/apptheme.popupoverlay" />         </android.support.design.widget.appbarlayout>          <include layout="@layout/content_main" />          <android.support.design.widget.floatingactionbutton             android:id="@+id/fab"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="bottom|end"             android:layout_margin="@dimen/fab_margin"             android:src="@android:drawable/ic_input_add"             android:tint="#ffffff" />     </android.support.design.widget.coordinatorlayout> 

content_main.xml:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     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"     app:layout_behavior="@string/appbar_scrolling_view_behavior"     tools:context="com.registrationmax.recordbook.mainactivity"     tools:showin="@layout/activity_main">      <listview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/experience_listview"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_alignparenttop="true" /> </relativelayout> 

layout custom list item:

<?xml version="2.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="?android:attr/listpreferreditemheight"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin">      <imageview         android:id="@+id/experience_list_item_photo"         android:layout_width="wrap_content"         android:layout_height="fill_parent"         android:contentdescription="todo"         android:layout_alignparenttop="true"         android:layout_alignparentright="true"         android:layout_alignparentend="true" />      <textview         android:id="@+id/experience_list_item_description"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_alignwithparentifmissing="true"         android:gravity="center_vertical"         android:text="description (line 1)"         android:textsize="16sp"         android:layout_margintop="4dip"         android:layout_alignparenttop="true"         android:layout_alignparentright="true"         android:layout_alignparentend="true" />      <textview         android:id="@+id/experience_list_item_date"         android:layout_width="fill_parent"         android:layout_height="26dip"         android:ellipsize="marquee"         android:singleline="true"         android:text="description (line 2)"         android:textsize="12sp"         android:layout_below="@+id/experience_list_item_description"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true" />  </relativelayout> 

you need remove layout_gravity activity_main.xml layout , use layout_anchor , layout_anchorgravity below

<include      android:id="@+id/include_main_layout"     layout="@layout/content_main" />  <android.support.design.widget.floatingactionbutton     android:id="@+id/fab"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     app:layout_anchor="@id/include_main_layout"     app:layout_anchorgravity="bottom|end"     android:src="@android:drawable/ic_input_add"     android:tint="#ffffff" /> 

you can read more here


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -