Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple android GridViews won't wrap_content
    text
    copied!<p>I've got an <code>Activity</code> that displays 5<code>GridViews</code>. Each of these <code>GridViews</code> is divided by a <code>TextView</code> with a background that spans the width of the screen. The <code>GridViews</code> represent a volume of books, and each item in the grid is a <code>Button</code> representing a book in a volume.</p> <p>All the <code>GridViews</code> and <code>TextViews</code> sit inside a <code>RelativeLayout</code>. Some Volumes have many books and others just a few, so I've been trying to get the individual grid views to <code>wrap_content</code> and take up all the space they need to show all of their books, but no luck. The <code>View</code> equally divides space to each of the <code>GridViews</code>, hiding most of the books. I have my xml layout below. Can anyone tell me how I can get this done? </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:as="http://schemas.android.com/apk/res/edu.byu.scriptures" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;RelativeLayout android:id="@+id/gridNavBar" android:layout_height="44px" android:layout_width="fill_parent" android:background="@drawable/bgnd_1_44" android:paddingBottom="0px"&gt; &lt;Button android:id="@+id/homeButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginLeft="5px" android:text="Home" android:textSize="14sp" android:textColor="#fff" android:shadowColor="#444" android:shadowRadius="1" android:shadowDx="1" android:shadowDy="-1" android:background="@drawable/generic_button_xml"/&gt; &lt;TextView android:id="@+id/bookRef" android:text="Books" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:textColor="#fff" android:textSize="18sp" android:textStyle="bold" android:shadowColor="#444" android:shadowRadius="1" android:shadowDx="1" android:shadowDy="-1" /&gt; &lt;/RelativeLayout&gt; &lt;ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/gridNavBar"&gt; &lt;RelativeLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;TextView android:gravity="top" android:id="@+id/vol1DividerBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Volume 1" android:textColor="#000" android:background="@drawable/volume_divider" android:layout_centerHorizontal="true" android:layout_alignParentTop="true"/&gt; &lt;GridView android:layout_weight="1" android:id="@+id/vol1Grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:layout_below="@id/vol1DividerBar"/&gt; &lt;TextView android:layout_weight="1" android:id="@+id/vol2DividerBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Volume 2" android:textColor="#000" android:background="@drawable/volume_divider" android:layout_below="@id/vol1Grid"/&gt; &lt;GridView android:layout_weight="1" android:id="@+id/vol2Grid" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:layout_below="@id/vol2DividerBar"/&gt; &lt;TextView android:layout_weight="1" android:id="@+id/vol3DividerBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Volume 3" android:textColor="#000" android:background="@drawable/volume_divider" android:layout_below="@id/vol2Grid"/&gt; &lt;GridView android:layout_weight="1" android:id="@+id/vol3Grid" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:layout_below="@id/vol3DividerBar"/&gt; &lt;TextView android:layout_weight="1" android:id="@+id/vol4DividerBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="The Doctrine and Covenants" android:textColor="#000" android:background="@drawable/volume_divider" android:layout_below="@id/vol3Grid"/&gt; &lt;GridView android:layout_weight="1" android:id="@+id/vol4Grid" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:layout_below="@id/vol4DividerBar"/&gt; &lt;TextView android:layout_weight="1" android:id="@+id/vol5DividerBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="The Pearl of Great Price" android:textColor="#000" android:background="@drawable/volume_divider" android:layout_below="@id/vol4Grid"/&gt; &lt;GridView android:layout_weight="1" android:id="@+id/vol5Grid" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:layout_below="@id/vol5DividerBar"/&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload