android - FloatingActionButton default margin not working in lollipop -


i displaying floatingactionbutton along recyclerview in coordinatorlayout, when fab clicked row added in recyclerview. problem fab has margin when tested in api 15 when test in api 22(lollipop 5.1.1-nexus 4) not margin , fab pressed edge of screen.

my concern fab has default margin setup in api 15(didnt test other devices) not in api 22 or missing something.

my layout code:

<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#6fbababa"     android:fitssystemwindows="true">      <android.support.v7.widget.recyclerview         android:id="@+id/my_recycler_view"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:cliptopadding="false"         android:paddingbottom="@dimen/fab_padding_bottom"         android:scrollbars="vertical"         app:layout_behavior="@string/appbar_scrolling_view_behavior" />      <android.support.design.widget.appbarlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#ffffff">          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:fitssystemwindows="true"             android:orientation="horizontal"             app:layout_scrollflags="scroll|enteralwayscollapsed">             ---------------------             ---------------------             </linearlayout>      </android.support.design.widget.appbarlayout>      <android.support.design.widget.floatingactionbutton         android:id="@+id/button_floating_action"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:clickable="true"         android:src="@drawable/ic_plus"         app:borderwidth="0dp"         app:layout_anchor="@id/my_recycler_view"         app:layout_anchorgravity="bottom|right|end"         app:ripplecolor="@color/wallet_highlighted_text_holo_light" />  </android.support.design.widget.coordinatorlayout> 

enter image description here

i ended using api-specific margin values. action button this:

    <android.support.design.widget.floatingactionbutton     android:contentdescription="@string/menu_compose"     android:id="@+id/action"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:clickable="true"     android:src="@drawable/ic_create_white"     android:layout_gravity="bottom|right|end"     android:layout_marginbottom="@dimen/action_button_margin"     android:layout_marginright="@dimen/action_button_margin"     android:layout_marginend="@dimen/action_button_margin"     app:elevation="6dp"     app:pressedtranslationz="12dp"     app:fabsize="normal"/> 

@dimen/action_button_margin defined in both values/dimens.xml:

<dimen name="action_button_margin">0dp</dimen> 

and in values-v21/dimens.xml:

<dimen name="action_button_margin">16dp</dimen> 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -