Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android text clipping problem with EditView inside a TableLayout

I've got a small clipping problem that I haven't been able to solve using an EditText view in a TableRow. Whatever I try, the EditText view is either clipped (attached screenshot), or, if I set shrinkColumns to either 0 or 1, the label text disappears (and the EditText view takes up the whole width). The layout is as follows:

<?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:orientation="vertical" android:padding="10dip">

  <TableLayout android:orientation="vertical"
  android:layout_width="fill_parent" android:layout_height="fill_parent">

    <TableRow android:orientation="horizontal"
    android:layout_width="fill_parent" android:layout_height="wrap_content">

      <TextView android:paddingRight="10dip" android:layout_column="1"
      android:text="Label Text" />
      <EditText android:text="Very long text that makes the text view go on clipping frenzy"
      android:layout_width="wrap_content" android:layout_height="wrap_content" />

    </TableRow>

  </TableLayout>

</LinearLayout>

I've tried it on a 2.2 emulator running at QVGA and HVGA, a HTC Hero on 2.1 and the Wildfire on 2.1 as well. I've also played around with the clipToPadding attribute which doesn't seem to help in my case. The same issue appears if I set the hint attribute with a long text and leave the text value empty.

As I am doing nothing particularly complex, I suspect a simple error on my side. Any ideas, hints or suggestions are highly appreciated.

Cheers!

alt text

like image 785
Alpha Hydrae Avatar asked Feb 25 '23 20:02

Alpha Hydrae


1 Answers

Set android:shrinkColumns="1" on your TableLayout, and remove android:layout_column="1" from the TextView.

like image 146
Romain Guy Avatar answered Apr 26 '23 21:04

Romain Guy