after I run my application I get large gap between RecyclerView items !! this is my code here : Github Large gap between recyclerview items
Asked
Active
Viewed 4,870 times
3
-
Share your xml file – Uttam Panchasara Sep 13 '16 at 18:23
-
you can see it here https://github.com/userRidae/RecyclerView/tree/master/app/src/main/res/layout – Ridae HAMDANI Sep 13 '16 at 18:26
1 Answers
10
Change your Layouts like this
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.breuhteam.recyclerview.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
view_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/itemView"
android:src="@drawable/diy"
android:layout_margin="1dp"
android:adjustViewBounds="true"/>
</RelativeLayout>
Uttam Panchasara
- 5,420
- 4
- 24
- 41
-
thanks it work for me but when I scoll down and I want to go back to up item some item size change – Ridae HAMDANI Sep 13 '16 at 18:42
-
it's because of recyclerview every time create the new view, you have to setTag for your items. – Uttam Panchasara Sep 13 '16 at 18:44
-
-
example : http://stackoverflow.com/questions/26889361/getting-a-reference-to-viewholder-on-recyclerview-click – Uttam Panchasara Sep 13 '16 at 18:50
-
-
The layout_margin and adjustViewBounds properties are important and not mentioned by most answers. – Michele Dorigatti Aug 02 '20 at 16:20