RecyclerView remove divider / decorator after the last item

Try this Code, it won’t show divider for the last item. This method will give you more control over drawing divider. public class DividerItemDecorator extends RecyclerView.ItemDecoration { private Drawable mDivider; public DividerItemDecorator(Drawable divider) { mDivider = divider; } @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { int dividerLeft = parent.getPaddingLeft(); int dividerRight = … Read more

How to add dividers between specific menu items?

You should use action layout <menu 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” tools:context=”.LandingActivity”> <item android:id=”@+id/action_cart” android:title=”cart” android:actionLayout=”@layout/cart_update_count” android:icon=”@drawable/shape_notification” app:showAsAction=”always”/> </menu> and then the action layout can have the textview with divider. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:orientation=”vertical”> <View android:id=”@+id/divider” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@drawable/divider”/> <TextView android:id=”@android:id/text” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”?android:attr/selectableItemBackground” android:gravity=”center_vertical” android:textAppearance=”?attr/textAppearanceListItemSmall”/> </LinearLayout> then you can add the click listener in code

Android GridView draw dividers

In case you want just simple lines as borders, much, much simpler is setting a background color for a GridView and proper padding & spacing: <GridView (…) android:background=”@color/LightGold” android:listSelector=”@android:color/transparent” android:horizontalSpacing=”1dip” android:verticalSpacing=”1dip” android:paddingLeft=”1dip” android:paddingTop=”1dip” />

How to add (vertical) divider to a horizontal LinearLayout?

use this for horizontal divider <View android:layout_width=”1dp” android:layout_height=”match_parent” android:background=”@color/honeycombish_blue” /> and this for vertical divider <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”@color/honeycombish_blue” /> OR if you can use the LinearLayout divider, for horizontal divider <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <size android:height=”1dp”/> <solid android:color=”#f6f6f6″/> </shape> and in LinearLayout <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:divider=”@drawable/divider” android:orientation=”vertical” android:showDividers=”middle” > If you … Read more

Android ListView Divider

Folks, here’s why you should use 1px instead of 1dp or 1dip: if you specify 1dp or 1dip, Android will scale that down. On a 120dpi device, that becomes something like 0.75px translated, which rounds to 0. On some devices, that translates to 2-3 pixels, and it usually looks ugly or sloppy For dividers, 1px … Read more

How to add dividers and spaces between items in RecyclerView

October 2016 Update The version 25.0.0 of Android Support Library introduced the DividerItemDecoration class: DividerItemDecoration is a RecyclerView.ItemDecoration that can be used as a divider between items of a LinearLayoutManager. It supports both HORIZONTAL and VERTICAL orientations. Usage: DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()); recyclerView.addItemDecoration(dividerItemDecoration); Previous answer Some answers either use methods that have since … Read more