View中的TextView无法正常工作

时间:2017-11-30 21:37:02

标签: android view textview

我正在添加更多不需要的假细节因为stackoverflow.com坚持这样做........ aaaand它拒绝发布我的问题

所以关于我正在构建3个相等的框元素,但是:

我添加<TextView/>时,布局停止工作......为什么会这样?

<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>

1 个答案:

答案 0 :(得分:1)

您无法在查看中使用其他观看次数(TextViewEditTextsButtons)。

试试这个:

<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>

如果您想在每个视图中使用更多文字视图,请使用线性,相对或其他 LayoutView

玩得开心