android - TextView 不会填满父宽度

标签 android css

我有一个表格布局,有两行。

Textview 的宽度不会填满表格行的整个宽度,但它填满了高度。

表格行的大小正确,填充了一半的高度和整个宽度。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </TableRow>

    <TableRow
        android:layout_weight="1"
        android:id="@+id/tableRow2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </TableRow>

</TableLayout>

最佳答案

添加到你的 TextView

android:layout_weight="1"

关于android - TextView 不会填满父宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24548338/

相关文章:

java - 如何根据用户的触摸移动图像?

android - Robolectric:如何从 Assets 中修复 FileNotFoundException?

javascript - 我如何使用 jquery 在文本字段中添加不同的字体颜色

html - 直接在 CSS 中嵌入自定义字体

css - 有两个相同元素的 CSS 使内联一个工作

android - context.getApplicationInfo().name 始终为空

android - 使用 setGraph() 以编程方式设置图形会导致应用程序无法在进程终止后恢复堆栈(Jetpack 导航)

java - Android 7服务gps更新

internet-explorer - IE7 中的字体系列 CSS3

javascript - 一个接一个淡入p个标签