TransWikia.com

RecyclerView проблема с полосками

Stack Overflow на русском Asked on December 7, 2021

Проблема в том, что после каждого элемента появляется вертикальная полоса. Не могу понять откуда она берётся, и как её убрать? введите сюда описание изображения

MainActivity.java

   recyclerView = (RecyclerView) findViewById(R.id.recycler_view99);

            recyclerView.addItemDecoration(new DividerItemDecoration(IndexActivity.this, LinearLayoutManager.HORIZONTAL));
            RecyclerViewHorizontalListAdapter groceryAdapter = new RecyclerViewHorizontalListAdapter(newCollectionsModels, getApplicationContext());
            recyclerView.setHasFixedSize(true);

            LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(IndexActivity.this, LinearLayoutManager.HORIZONTAL, false);
            recyclerView.setLayoutManager(horizontalLayoutManager);
            recyclerView.setAdapter(groceryAdapter);

RecyclerViewHorizontalListAdapter.java

    public class RecyclerViewHorizontalListAdapter extends RecyclerView.Adapter<RecyclerViewHorizontalListAdapter.GroceryViewHolder>{
    private List<NewCollectionsModel> horizontalGrocderyList;
    Context context;

    public RecyclerViewHorizontalListAdapter(List<NewCollectionsModel> horizontalGrocderyList, Context context){
        this.horizontalGrocderyList = horizontalGrocderyList;
        this.context = context;
    }

    @Override
    public GroceryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View groceryProductView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycle_view_index_new_collection, parent, false);
        GroceryViewHolder gvh = new GroceryViewHolder(groceryProductView);
        return gvh;
    }

    @Override
    public void onBindViewHolder(GroceryViewHolder holder, final int position) {
        holder.txtview.setText(horizontalGrocderyList.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return horizontalGrocderyList.size();
    }

    public class GroceryViewHolder extends RecyclerView.ViewHolder {
        TextView txtview;
        public GroceryViewHolder(View view) {
            super(view);
            txtview=view.findViewById(R.id.rv2_new_collections_tv);
        }
    }
}

recycle_view_index_new_collection.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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:orientation="vertical"

>
<TextView
    android:id="@+id/rv2_new_collections_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="7dp"
    android:fontFamily="@font/futura_bt_book"
    android:text="О бренде"
    android:textColor="@android:color/black"
    android:textSize="12sp"
    android:visibility="visible"
    android:layout_gravity="center_horizontal"
    />

One Answer

Полоски рисует декоратор DividerItemDecoration, который вы добавили в RecyclerView

recyclerView.addItemDecoration(new DividerItemDecoration(IndexActivity.this, LinearLayoutManager.HORIZONTAL));

Answered by IR42 on December 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP