Hi I am developing small android application in which I want to display simple gridview with some elements.Its working properly. Only problem is that it is always showing only two columns even though there is space. Its is equally dividing screen into 2 columns and displaying only two elements.If I set number of columns as number i.e. not auto_fit then it is showing properly. My code looks like:
<FrameLayout 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"
>
<GridView
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="5dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp">
</GridView>
</FrameLayout>
and my grid element looks like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.androidcardlayout.MainActivity" >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="100dp"
android:layout_height="150dp"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:id="@+id/cardMianRlt"
android:layout_width="100dp"
android:layout_height="150dp"
>
</RelativeLayout>
Am I doing anything wrong? Need Some help. Thank you.