Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: TextView takes up space with no text

I have a TextView that is still taking up space when there is no text to display. This happens only on OS 1.6. When my app runs on 2.2, the height of the TextView collapses so that it doesn't take up any space. Is there some property I can set in TextView to cause it to collapse or disappear when no text is set? Here is my xml code.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center"
  android:layout_marginTop="3dp"
  android:layout_marginRight="3dp" 
  android:background="#ff737373"
  android:padding="3dp"
  android:minWidth="64dp" >
  <ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:tag="tabImage"></ImageView>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:tag="tabCaption"
    android:textColor="#ffd9d9d9" />
</LinearLayout>
like image 910
Johann Avatar asked Oct 11 '11 09:10

Johann


1 Answers

If you want to make a textview disappear if its text is null then use android:visibility or programatically use textview.setVisibility(View.INVISIBLE); or textview.setVisibility(View.GONE);.

like image 92
Paresh Mayani Avatar answered Oct 20 '22 03:10

Paresh Mayani