Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid How to stretch rows in the gridview to fill screen?
    primarykey
    data
    text
    <p>I have simple GridView (with one column and six rows), that displays ImageView with TextView in the cell (I create adapter). How to stretch rows to fill entire screen height?? Now I have some space below cells... </p> <p>main.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"&gt; &lt;LinearLayout android:layout_height="fill_parent" android:layout_width="150dp" android:orientation="vertical" android:id="@+id/left"&gt; &lt;include layout="@layout/menu_grid"&gt;&lt;/include&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" android:id="@+id/right"&gt; &lt;ImageView android:src="@drawable/image" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageMain" android:layout_gravity="center"&gt; &lt;/ImageView&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>menu_grid.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;GridView android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/gridView" android:padding="10dp" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:numColumns="1" android:columnWidth="100dp" android:stretchMode="columnWidth" android:gravity="center"&gt;&lt;/GridView&gt; </code></pre> <p></p> <p>item.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="fill_horizontal"&gt; &lt;ImageView android:src="@drawable/icon" android:layout_height="70dp" android:id="@+id/imageIcon" android:layout_width="70dp" android:layout_gravity="center_horizontal"&gt;&lt;/ImageView&gt; &lt;TextView android:id="@+id/textIcon" android:text="TextView" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt;&lt;/TextView&gt; </code></pre> <p></p> <p>ImageAdapter.java</p> <pre><code>public class ImageAdapter extends BaseAdapter { //....some code //.... @Override public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { LayoutInflater inflater = (LayoutInflater)_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.item, null); TextView text = (TextView) view.findViewById(R.id.textIcon); text.setText(labels[position]); ImageView image = (ImageView) view.findViewById(R.id.imageIcon); image.setImageResource(icons[position]); } else { view = convertView; } return view; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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