TableRow TextView向下移动较长的文本

时间:2018-02-04 19:30:09

标签: android android-layout textview tablelayout tablerow

我尝试使用带有TextView的TableLay的TableLayout为我的学校制作一个时间表应用程序。问题是,当我输入较长的文本时,TextView会向下移动。 这是我的xml:     `

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

        <TextView
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:text="Mo"
            android:background="#ffffff"
            android:gravity="center"
            android:layout_margin="1dp"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:gravity="center"
            android:text="Tu"
            android:background="#ffffff"
            android:layout_margin="1dp"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:text="WeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWe"
            android:gravity="center"
            android:background="#ffffff"
            android:layout_margin="1dp"
            />

    </TableRow>
</TableLayout>`

email your users

1 个答案:

答案 0 :(得分:0)

您的布局类型的更新。 这似乎工作正常。根据需要更改textColor和其他参数

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TableRow
        android:id="@+id/tableRow"
        android:layout_width="wrap_content"
        android:layout_height="60dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:layout_margin="1dp"
            android:background="#ffffff"
            android:text="Mo"
            android:textColor="@color/colorPrimaryDark" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:layout_margin="1dp"
            android:background="#ffffff"
            android:text="Tu"
            android:textColor="@color/colorPrimaryDark" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_margin="1dp"
            android:background="#ffffff"
            android:gravity="center"
            android:text="WeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWeWe"
            android:textColor="@color/colorPrimaryDark" />

    </TableRow>

</TableLayout>

</RelativeLayout>