2

I know there are a lot of questions like this on the forums, but many cases are unique, so here goes.

I have a custom list view that displays an "event" in different ways based on the application theme. The text for the title, alt-text and tags are all getting cut off (regardless of what the height is set to). Can you please help me fix the problem?

The text is cut off in two of my 3 themes, and only on the actual device (not emulator).

The code for each list item is very similar, so I'm attaching only one below (and will attach the others if needed); thanks.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!-- ?android:attr/listPreferredItemHeight -->
<LinearLayout android:id="@+id/viewrow_flags"
    android:orientation="vertical" android:layout_width="36px"
    android:layout_height="80px" android:layout_marginRight="6dip">
</LinearLayout>
<LinearLayout android:orientation="vertical"
    android:layout_width="0dip" android:layout_weight="1"
    android:layout_height="fill_parent">
    <TextView android:id="@+id/viewrow_toptext"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:singleLine="true" android:layout_weight="1" android:gravity="center_vertical"
        android:textColor="#00ccFF" android:textSize="6pt" android:paddingBottom="1dip"/>
    <TextView android:layout_width="fill_parent" android:gravity="center_vertical"
        android:layout_height="fill_parent" android:layout_weight="1"
        android:id="@+id/viewrow_bottomtext" android:textColor="#0066FF"
        android:singleLine="true" android:textSize="6pt" android:paddingBottom="1dip"/>
    <TextView android:layout_width="fill_parent" android:gravity="center_vertical"
        android:layout_height="fill_parent" android:layout_weight="1"
        android:id="@+id/viewrow_tagtext" android:textColor="#0066FF"
        android:singleLine="true" android:textSize="6pt" android:paddingBottom="1dip"/>
</LinearLayout>
<View android:id="@+id/viewrow_anchor" android:layout_width="0sp"
    android:layout_height="60dip" android:layout_gravity="center" />
<TextView android:id="@+id/viewrow_dayview"
    android:layout_width="60sp" android:layout_height="80px"
    android:gravity="center" android:paddingLeft="6dip"
    android:paddingTop="12dip" />
</LinearLayout>
Blaskovicz
  • 6,122
  • 7
  • 41
  • 50

4 Answers4

3

I figured out the problem, it was a mixture of layout weight and overall view list item height.

        <LinearLayout android:orientation="vertical"
            android:layout_width="0dip" 
            android:layout_weight="1"
            android:layout_height="fill_parent">
-               <TextView android:id="@+id/viewrow_toptext" 
                          android:layout_weight="1"
+               <TextView android:id="@+id/viewrow_toptext"
                          android:layout_width="fill_parent"                              
                          android:layout_height="fill_parent"
-                         android:singleLine="true" 
                          android:ellipsize="end" 
                          android:gravity="center_vertical"
+                         android:singleLine="true" 
                          android:layout_weight="1" 
                          android:gravity="center_vertical"
                          android:textColor="#00ccFF" 
                          android:textSize="6pt" 
                          android:paddingBottom="1dip"/>
-               <TextView android:layout_width="fill_parent"
-                         android:ellipsize="end"
+               <TextView android:layout_width="fill_parent"     
                          android:gravity="center_vertical"
                          android:layout_height="fill_parent" 
                          android:layout_weight="1"
                          android:id="@+id/viewrow_bottomtext" 
                          android:textColor="#0066FF"
                          android:singleLine="true" 
                          android:textSize="6pt" 
                          android:paddingBottom="1dip"/>
-               <TextView android:layout_width="fill_parent"
-                         android:ellipsize="end"
+               <TextView android:layout_width="fill_parent" 
                          android:gravity="center_vertical"
                          android:layout_height="fill_parent" 
                          android:layout_weight="1"
                          android:id="@+id/viewrow_tagtext" 
                          android:textColor="#0066FF"
                          android:singleLine="true" 
                          android:textSize="6pt" 
                          android:paddingBottom="1dip"/>
    </LinearLayout>
                <View android:id="@+id/viewrow_anchor" 
                      android:layout_width="0sp"
-                     android:layout_height="70dip" 
                      android:layout_gravity="center" />
+                     android:layout_height="60dip" 
                      android:layout_gravity="center" />
    <TextView android:id="@+id/viewrow_dayview"
              android:layout_width="60sp" 
              android:layout_height="80px"
              android:gravity="center" 
              android:paddingLeft="6dip"
alecnash
  • 1,750
  • 1
  • 18
  • 42
Blaskovicz
  • 6,122
  • 7
  • 41
  • 50
2

You have your TextViews defined as single lines with android:singleLine="true". So, if the text is too big for the space, it will be cropped. Either set the TextViews up to allow for wrapping of texting and expanding their height OR you could use the android:ellipsize="marquee" attribute to display the text on a single line.

SBerg413
  • 14,515
  • 6
  • 62
  • 88
  • What is the difference between the two variables? I looked it up on the android docs and it says that ellipsize will typically be used with android:singleLine. – Blaskovicz Oct 10 '11 at 12:42
  • Yes, ellipsize is for single line. Will crop w/ ending dots OR for android:ellipsize="marquee" will scroll the text from left to right like a marquee. If you have the room, use multi-line though. Better UI – SBerg413 Oct 10 '11 at 14:29
  • Setting this property didn't solve the problem - i'm guessing it has something to do the text views and their layout heights / weights. – Blaskovicz Oct 10 '11 at 23:38
  • marquee doesn't scroll the text in my view (maybe because it's dynamically filled), but at least I was able to get rid of these 3 dots and the end of the second last word. – Bevor Sep 18 '16 at 08:32
1

add android:layout_weight="1" to those who are cut off

RoRo
  • 118
  • 9
  • I think I tried giving the three textviews the same layout_weight, but they were still cut off on my actual device. I will confirm this later. – Blaskovicz Oct 10 '11 at 12:44
  • I tried setting all the inner text views to have the same weight, but this didn't solve the problem. – Blaskovicz Oct 10 '11 at 23:39
0

just change layout_height="fill_parent" in linear to wrap_content

<LinearLayout android:orientation="vertical"
    android:layout_width="0dip" android:layout_weight="1"
    android:layout_height="fill_parent">
    <TextView android:id="@+id/viewrow_toptext"
user3339005
  • 23
  • 1
  • 2