0

this is screenshot am getting output .after first and second listitem there should be space and not occupying right side want to occupy background blue coloc

Between id1 and id2 want some space In the below layout am displaying recylerview list of items having two attributes are there one is title and listview.

want to space between list of items should occupy full screen.

layoutfile

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_create_account"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="User Info"
        android:layout_centerInParent="true"
        android:gravity="top"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:layout_marginTop="20dp"
        android:dividerHeight="10.0sp"/>

</LinearLayout>

In the below xml am displaying list of items available like name , email and phone these are the attributes in the list

list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_create_account"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@color/colorBlue">

    <TextView
        android:id="@+id/user_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:textColor="@color/colorWhite"
        android:gravity="center"
        android:text="ID"
        android:textSize="16dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/user_id"
        android:textColor="@color/colorWhite"/>

    <TextView
        android:id="@+id/email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/name"
        android:textColor="@color/colorWhite" />
    <TextView
        android:id="@+id/phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/email"
        android:textColor="@color/colorWhite" />
</LinearLayout>
</LinearLayout>
Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39

3 Answers3

0

You should use

android:layout_weight

you can find information about the weight on this answer. Just adapt it to layout_height instead of layout-with.

Milind Mevada
  • 3,145
  • 1
  • 14
  • 22
Thibault
  • 1
  • 3
0

use android:layout_marginBottom="20dp" to your parent view LinearLayout of list.xml

0

Your main goal is highlight particular item..

  1. use divider

here the example : https://medium.com/@szholdiyarov/how-to-add-divider-to-list-and-recycler-views-858344450401

DividerItemDecoration itemDecor = new DividerItemDecoration(getContext, HORIZONTAL);

<!--addItemDecoration to recyclerView -->

recyclerView.addItemDecoration(itemDecor);

You can also change its orientation using itemDecor.setOrientation(VERTICAL) or drawable image by calling a method itemDecor.setDrawable(Drawable divider).

But sometimes you need to customise the way of drawing the divider. For example, you might want to change the divider’s colour on the last element or to not draw a line for the first item.

  1. use padding or margin as shreya-prajapati suggested..
Ashvin solanki
  • 4,802
  • 3
  • 25
  • 65