Reputation: 7105
I have this layout for a gridview which i'm using to display some images and texts that i take from a JSON object. I created this gridview so that i ahows only 2 columns and it was working fine. But when i wanted to change it to 3 columns my gridview images become so small and textview is shown like a vertical line. Why does it work for android:numColumns="2" and not for android:numColumns="3"?
gridview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@color/grey"
android:id="@+id/theater_fragment" >
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:gravity="center"
android:horizontalSpacing="5dp"
android:numColumns="3"
android:verticalSpacing="5dp" >
</GridView>
</RelativeLayout>
single gridview item
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/image_theater"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"/>
<TextView
android:id="@+id/theater_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/image_theater"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
Upvotes: 0
Views: 93
Reputation: 3339
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Upvotes: 1