Rafael Toledo
Rafael Toledo

Reputation: 5659

ImageView isn't showed on TableRow

I have the following code to create a table header in my code. But, for some reason, the column with ImageView don't show anything. As I fixed weight for the columns, instead of show the image, this code only reserves a empty space for the column, but don't show anything. I suspected that my drawable was the origin of this, but if I create a TextView and define it as drawableTop, drawableBottom or another type of this, it is showed.

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp" >

    <TableRow>

        <TextView
            android:layout_margin="1dp"
            android:layout_weight="2"
            android:background="#ffcccccc"
            android:gravity="center"
            android:text="@string/date_hour"
            android:textSize="16sp"
            android:textStyle="bold" />

        <ImageView
            android:layout_margin="1dp"
            android:layout_weight=".75"
            android:background="#ffcccccc"
            android:gravity="center"
            android:drawable="@drawable/road" />

        <TextView
            android:layout_margin="1dp"
            android:layout_weight=".75"
            android:background="#ffcccccc"
            android:gravity="center"
            android:text="@string/op"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:layout_margin="1dp"
            android:layout_weight="1"
            android:background="#ffcccccc"
            android:gravity="center"
            android:text="@string/tag"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:layout_margin="1dp"
            android:layout_weight="2"
            android:background="#ffcccccc"
            android:gravity="center"
            android:text="@string/status"
            android:textSize="16sp"
            android:textStyle="bold" />
    </TableRow>
</TableLayout>

Did someone experienced same problem?

Upvotes: 1

Views: 172

Answers (1)

karan
karan

Reputation: 8853

I guess your imageview should be as below

<ImageView
        android:layout_margin="1dp"
        android:layout_weight=".75"
        android:background="#ffcccccc"
        android:gravity="center"
        android:src="@drawable/road" />

try and replace this in your code. hope it works

Upvotes: 2

Related Questions