Posts Tagged ‘clipToPadding’

Now a days we are using Android Design Library to have rich look.

I’ve faced this problem while integrating RecyclerView with FAB (Floating Action Button) and I was not able to read the last line of it due to FAB was overlapping it.

I’ve tried this (Wrong assumption):


<android.support.v7.widget.RecyclerView 
android:id="@+id/my_recycler_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding_bottom="30dp"
/>

After some research found that its very easy to implement :

Method 1: Create Style

<style name="rvWithClipPadding">
<item name="android:clipToPadding">false</item>
<item name="android:paddingBottom">@dimen/margin_56dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:scrollbars">vertical</item>
</style>

use this style in xml,

<android.support.v7.widget.RecyclerView 
android:id="@+id/my_recycler_view" 
style="@style/rvWithClipPadding"
/>

Method 2: Use attributes while creating

<android.support.v7.widget.RecyclerView 
android:id="@+id/my_recycler_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:clipToPadding="false" 
android:paddingBottom="30dp" 
android:scrollbars="vertical"/>

 

Advertisements