Android RecyclerView Spacing Differences between Platforms



Disclosure up front, this is a school project.


I've run into a somewhat confusing-to-me layout issue regarding a list of CardViews inside of a RecyclerView, that being that the spacing between cards is non-existent on 5.0, whereas it's fine on 4.4. Here's two screenshots to demonstrate.


Android 4.4 (On Device, Galaxy S4) 4.4


Android 5.0.1 (On Device, Nexus 4) 5.0.1


I can see the card corners in the 5.x version, so the cards are there. I have a feeling this is something to do with some XML attribute that I need for running 5.x that the support library fakes automatically on 4.x, but googling has failed me. Here's the relevant XML:


Fragment Layout



<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hinodesoftworks.kanagt.HiraganaListFragment">

<android.support.v7.widget.RecyclerView
android:id="@+id/hira_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>


Card Layout



<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://ift.tt/nIICcg"
xmlns:card_view="http://ift.tt/GEGVYd"
android:layout_height="match_parent"
android:layout_width="match_parent"
card_view:cardCornerRadius="4dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/kana_card_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="46sp"
android:text="あ"/>

<TextView
android:id="@+id/kana_card_roma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/kana_card_display"
android:layout_toEndOf="@id/kana_card_display"
android:text="a"
/>

<TextView
android:id="@+id/kana_card_info1_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/kana_card_display"
android:layout_toEndOf="@id/kana_card_display"
android:layout_below="@id/kana_card_roma"
android:text="INFO 1"/>

<TextView
android:id="@+id/kana_card_info2_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/kana_card_display"
android:layout_toEndOf="@id/kana_card_display"
android:layout_below="@id/kana_card_info1_display"
android:text="INFO 2"/>

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/kana_card_info2_display">
<ImageView
android:id="@+id/kana_card_diagram"
android:layout_width="match_parent"
android:layout_height="100dp"
android:scaleType="fitStart"

android:adjustViewBounds="true"/>
</HorizontalScrollView>
</RelativeLayout>

</android.support.v7.widget.CardView>


I'm really hoping this is a dumb mistake with a simple XML fix; that the support library version is working fine makes me hopeful of that.


No comments:

Post a Comment