K20GH
K20GH

Reputation: 6263

Remove XML component instead of hiding?

I've got a layout which displays my date and then some code in a LinearLayout like so:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="16dp">

    <TextView
        android:id="@+id/message_date"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textColor="@color/grey_500"
        android:textSize="16sp"
        android:text="wefwefwef"
        android:textStyle="normal"
        />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView"
        android:id="@+id/orange_message"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textColor="#000000"
        android:textSize="20sp"
        android:textStyle="bold"
        />

</LinearLayout>

Basically, what I want to do in my Java is to hide the TextView message_date. I am currently doing this using setVisibility(View.INVISIBLE)

This works, but it seems to keep the styling on message_date so orange_message actually appears further down the view. Is there anyway I can set it so that it acts as is message_date was never there?

Upvotes: 0

Views: 52

Answers (1)

Ariel Carbonaro
Ariel Carbonaro

Reputation: 1539

use View.GONE

setVisibility(View.GONE)

Upvotes: 3

Related Questions