0

I have a GridLayout with this scheme

-COL0-COL1--COL2
[-------] [TEXTVIEW]
[-------] [TEXTVIEW]
[-IMG-] [RATINGBAR]
[-------] [TEXTVIEW]
[-------] [TV]--[TV]

So IMG have ROWSPAN=5
TEXTVIEW1,TEXTVIEW2,RATINGBAR,TEXTVIEW3 have colSpan=2;
TEXTVIEW1 and TEXTVIEW2 could have long text, it retrieves data from web.. That's the problem, if text is too long it just crops it.. I want text goes to new line if too long..

This is my XML

<GridLayout
    android:id="@+id/activity_schedabook_gridlayout_top"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:rowCount="5" >

    <ImageView
        android:id="@+id/activity_schedabook_imageview_copertina"
        android:layout_column="0"
        android:layout_gravity="left"
        android:layout_row="0"
        android:layout_rowSpan="5" />

    <TextView
        android:id="@+id/activity_schedabook_textview_titolo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_columnSpan="2"
        android:layout_gravity="left|center_vertical"
        android:layout_row="0"
        android:ellipsize="marquee"
        android:lines="2"
        android:marqueeRepeatLimit="marquee_forever"
        android:textSize="15sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/activity_schedabook_textview_sottotitolo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_columnSpan="2"
        android:layout_gravity="left"
        android:layout_row="1"
        android:ellipsize="marquee"
        android:lines="2"
        android:marqueeRepeatLimit="marquee_forever" />

    <RatingBar
        android:id="@+id/activity_schedabook_ratingbar"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_column="1"
        android:layout_columnSpan="2"
        android:layout_gravity="left"
        android:layout_row="2"
        android:isIndicator="true"
        android:max="5"
        android:numStars="5" />

    <TextView
        android:id="@+id/activity_schedabook_textview_autore"
        android:layout_column="1"
        android:layout_columnSpan="2"
        android:layout_row="3"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/activity_schedabook_textview_categoria"
        android:layout_column="1"
        android:layout_gravity="left"
        android:layout_row="4" />

    <TextView
        android:id="@+id/activity_schedabook_textview_sottocategoria"
        android:layout_column="2"
        android:layout_gravity="left"
        android:layout_row="4" />

</GridLayout>
Tizianoreica
  • 2,142
  • 3
  • 28
  • 43
  • There *is* a consistent way to use `TextView` inside `GridLayout`. Have a look at my answer here: http://stackoverflow.com/a/23090059/1208581 – sulai Apr 15 '14 at 17:04

2 Answers2

0

Here is the layout that the to create your view like:

<TextView 
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/primary_text_light_disable_only"
android:gravity="center_vertical"
android:paddingLeft="14dip"
android:paddingRight="15dip"
android:ellipsize="marquee"/>

As you can see the ellipsize is set to marquee, so I don't believe it was ever written with the intention to allow multilines.

There is a bug open at the moment that ellipse dots are never shown: http://code.google.com/p/android/issues/detail?id=10554

Dhruv
  • 1,862
  • 3
  • 20
  • 38
0

Center TextView in GridLayout here is the code:

 <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1"
                android:textSize="20sp"
                android:layout_gravity="center"
                android:textColor="#ffffff"
                android:id="@+id/addPoints"
                android:layout_columnSpan="2"
                android:layout_rowSpan="2"/>