Android : Android: RecyclerView items are misaligned after scrolling

on Thursday, March 26, 2015


I have a recyclerview using a gridlayoutmanager with a span count of 2. The items in the grid show up properly when they are first loaded but after scrolling down a bit some of the views (the right column in the grid) become misaligned. Sometimes scrolling back down a bit will realign some of the views. They are only misaligned by a fraction but its still noticeable. Was wondering if anyone else has experienced this. Could it be something to do with the way I have defined the xml layout for the items? Any tips or suggestions are much appreciated!



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="175dp"
android:layout_height="275dp"
>
<ImageView
android:id="@+id/product_image"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
<LinearLayout
android:id="@+id/product_info_container"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_marginTop="200dp"
android:background="#fff"
android:orientation="vertical"
android:padding="16dp"
>
<TextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
tools:text="T-Shirt"
/>
<TextView
android:id="@+id/price_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="$58"
/>
</LinearLayout>
</FrameLayout>

0 comments:

Post a Comment