AndroidStaggeredGrid
AndroidStaggeredGrid copied to clipboard
Wrong size when StaggeredGridView placed inside weighted layout
When i placed a StaggeredGridView inside a weighted layout like so:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:weightSum="5"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/spacer_left"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_gravity="bottom"
android:layout_width="0dp"
android:layout_height="wrap_content">
<com.nfl.now.ui.TypefaceTextView
style="@style/NFLNow.TextView.Light"
android:id="@+id/sponsor_text"
android:textSize="8sp"
android:text="@string/sponsor_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="SmallSp"/>
<ImageView
android:layout_below="@id/sponsor_text"
android:layout_marginTop="2dp"
android:src="@drawable/sponsor_logo"
android:layout_width="100dp"
android:layout_height="wrap_content" />
</RelativeLayout>
<GridView
android:id="@+id/favorite_players"
android:numColumns="5"
android:layout_below="@id/header"
android:layout_above="@id/footer"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<Space
android:id="@+id/spacer_right"
android:layout_weight="1"
android:layout_marginLeft="16dp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
The grid only shows 1 column despite the setting for 5. Upon further inspection, all 5 columns are being laid out, but they are being laid out on top of each other!
Could we get a fix? =)
I have the same problem, any fix for it?
I also seem to have the same issue. Any workarounds?
I've attached a dump of the current view hierarchy and a screenshot, for reference. If anyone has any suggestions, let me know.
I meet the same problem, is what the solution?
I meet the same problem, is what the solution?
The solution for us was to call setColumnCount on the UI thread of the activity