Jocky Doe
Jocky Doe

Reputation: 2161

TextView within View doesn't work

I am adding more not needed fake details because stackoverflow.com insist on doing so........ aaaand it refuses to post my question

So on the point I am building 3 equal boxes element but:

The moment I add the <TextView/> the layout stops working... why so?

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="74dp"
    android:background="@color/sevenBlack" >

    <TableRow
        android:layout_height="match_parent"
        android:weightSum="3">

        <View
            android:layout_height="match_parent"
            android:layout_weight="1">

            <!-- WTF!!! -->
            <TextView android:text="Hello there"/>

        </View>

        <View
            android:layout_height="match_parent"
            android:layout_weight="1"></View>

        <View
            android:layout_height="match_parent"
            android:layout_weight="1"></View>
    </TableRow>
</TableLayout>

Upvotes: 0

Views: 40

Answers (1)

Rafael Filipake
Rafael Filipake

Reputation: 114

You cannot use other Views (TextView, EditTexts, Buttons) inside of View.

Try this:

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="74dp"
    android:background="@color/sevenBlack" >

    <TableRow
        android:layout_height="match_parent"
        android:weightSum="3">

            <TextView android:text="Hello there"             
             android:layout_height="match_parent"
             android:layout_weight="1"/>

        <View
            android:layout_height="match_parent"
            android:layout_weight="1"></View>

        <View
            android:layout_height="match_parent"
            android:layout_weight="1"></View>
    </TableRow>
</TableLayout>

If you want to use more text views in each View use Linear,Relative or other LayoutView.

Have Fun

Upvotes: 1

Related Questions