简体   繁体   中英

android text in table gets cut off

I've been looking for an answer to this for a long long long time. I have the following code:

 <TableRow
    android:id="@+id/tableRow106"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp" 
    android:visibility="gone"
    android:background="@drawable/b02_light_bar">

    <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" >

   <Button
       android:id="@+id/button35"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="@drawable/b02_play_blue" 
       />

     <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:orientation="vertical"
       android:paddingLeft="5dp"
       >


   <TextView
       android:id="@+id/textView20"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textColor="#ffffff"
       android:text="@string/interaction2"
       android:textAppearance="?android:attr/textAppearanceMedium" />

   <TextView
       android:id="@+id/textView21"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textColor="#41c4dd"
       android:text="@string/interaction2cont"
       android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>


</LinearLayout>
</TableRow>

And my text in textview21 still gets cut off if it is too long. Anyone know how to solve this? I promise you, I tried everything!

I have copied your code and string and yes the problem is there..

I got one solution for you and that's

Remove android:padding="10dp" from TableRow tag and apply that in the LinearLayout right under the tableRow.

<TableRow
    android:id="@+id/tableRow106"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    android:background="@drawable/b02_light_bar">

    <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       >

   <Button
       android:id="@+id/button35"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="@drawable/b02_play_blue" 
       />

     <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:orientation="vertical"
       android:paddingLeft="5dp"
       >


   <TextView
       android:id="@+id/textView20"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textColor="#ffffff"
       android:text="@string/interaction2"
       android:textAppearance="?android:attr/textAppearanceMedium" />

   <TextView
       android:id="@+id/textView21"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textColor="#41c4dd"
       android:text="@string/interaction2cont"
       android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>


</LinearLayout>
</TableRow>

use the attribute android:maxLines="3"

Change your textview to

 <TextView
   android:id="@+id/textView21"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textColor="#41c4dd"
   android:maxLines="3"
   android:text="@string/interaction2cont"
   android:textAppearance="?android:attr/textAppearanceSmall" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM