2017-02-16 3 views
2

Я добавил андроид-recyclerview в моем приложении, которое работает нормально. Согласно моему расположению, мне нужно удалить разделитель между ячейками. В виде списка это можно легко достичь, установив свойство divider равным null, как показано ниже в коде, но я не могу найти такого свойства в android-recyclerview. Как я могу достичь этого в андроид-recyclerview.Как удалить разделитель по умолчанию из recylerview

getListView().setDivider(null); 
getListView().setDividerHeight(0); 
    OR 
android:divider="@null" 
android:dividerHeight="0dp" 

Recylerview XML ниже:

<android.support.v7.widget.RecyclerView 
       android:id="@+id/recycler_view_contact_list_frag" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.8" 
       android:clickable="true" 
       android:focusable="true" 
       android:scrollbars="vertical" /> 

Адаптер XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:background="@drawable/recyclerview_item_borders" 
android:padding="10dp"> 

<LinearLayout 
    android:id="@+id/section_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:visibility="gone" 
    android:paddingBottom="30dp" 
    > 


<TextView 
    android:id="@+id/textview_section_header" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    /> 

</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    > 
    <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/circular_image_contact" 
     android:layout_width="@dimen/auto_complete_circular_image_dimen" 
     android:layout_height="@dimen/auto_complete_circular_image_dimen" 
     app:civ_border_color="#FF000000" 
     android:layout_weight="0.2" 
     android:src="@mipmap/ic_default_contact" 
     app:civ_border_width="0dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="0.8" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/textView_contact_name" 
      android:layout_width="match_parent" 
      android:layout_gravity="center_vertical" 
      android:gravity="center_vertical" 
      android:layout_marginLeft="@dimen/activity_horizontal_margin" 
      android:textColor="@color/textDarkColor" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" /> 

     <TextView 
      android:id="@+id/textView_contact_number" 
      android:layout_width="match_parent" 
      android:layout_gravity="center_vertical" 
      android:gravity="center_vertical" 
      android:layout_marginLeft="@dimen/activity_horizontal_margin" 
      android:textColor="@color/textDarkColor" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" /> 


    </LinearLayout> 
</LinearLayout> 

+7

Recyclerview не имеет делителей по умолчанию – raktale

+0

множества андроида: dividerHeight = "0dp" в файле XML. –

+0

@SorathiyaPayal В Recylerview нет разделителей !!! обратитесь к этой ссылке https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html – raktale

ответ

0

Recyclerview не имеют разделитель по умолчанию. Если вам нужно добавить разделитель, вы должны добавить украшение в recyclerview.

0

Это пользовательский вид, который вы используете по умолчанию, нет делителя. делитесь своим кодом с любым, кто может вам помочь.

1

Удалить фон от адаптера

android:background="@drawable/recyclerview_item_borders" 
0

Вы должны изменить его в представлении элемента списка. Добавьте следующие параметры в список элементов списка.

card_view:cardCornerRadius="0dp" 
card_view:cardElevation="0dp" 
card_view:cardUseCompatPadding="true" 

В list_item_view.xml

<android.support.v7.widget.CardView 
    android:id="@+id/card_view" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    card_view:cardCornerRadius="0dp" 
    card_view:cardElevation="0dp" 
    card_view:cardUseCompatPadding="true"> 

Затем установите цвет фона вашего зрения корзины на ее цвет переднего плана. Если это белый,

В recycle_view.xml

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:background="#ffffff" 
    android:scrollbars="vertical" 
    android:layout_height="wrap_content"/> 
Смежные вопросы