I'm using a GridView in my code. I have a problem with space. This is my problem:
When the text is short no problem, but the problem is when are longer. I want to get this:
This is my GridView:
<GridView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:divider="@color/transparente"
android:horizontalSpacing="4dp"
android:longClickable="true"
android:numColumns="2"
android:scrollbars="none"
android:verticalSpacing="4dp" >
</GridView>
And this is the xml of the elements of the GridView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center_vertical"
android:paddingLeft="5dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="2dp" >
<TextView
android:id="@+id/textView_title_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text text text text text text"
android:textColor="@color/blanco"
android:textSize="@dimen/titulos" />
<TextView
android:id="@+id/textView_alarm_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text text text text text text"
android:textColor="@color/blanco"
android:textSize="@dimen/contenido" />
<TextView
android:id="@+id/textView_alarm_days"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text text text text text text"
android:textColor="@color/blanco"
android:textSize="@dimen/contenido" />
</LinearLayout>
</LinearLayout>
I tried to use android: stretchMode = "spacingWidth", "columnWidth" and android: verticalSpacing = "4DP"
... but without success
I searched for answers, but can not find anything to help me
I appreciate any help
Thanks and regards
You must declare the real max size. Setting in root layout any params won't help. You should set it separately in each of child elements. For example here is my code, please look at this two children elements, they have max possible height and width. I think setting width doesn't matter but I might be in mistake. However the height size must be setted anyway. Please check this out and try in your project.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="150dp"
android:layout_height="200dp"
android:src="@drawable/stub"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="20dip"
android:ellipsize="end"
android:visibility="visible"
android:text="text" />
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With