Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有人能解释一下为什么该行没有在这个表格布局中包装文本吗?_Java_Android_Android Tablelayout - Fatal编程技术网

Java 有人能解释一下为什么该行没有在这个表格布局中包装文本吗?

Java 有人能解释一下为什么该行没有在这个表格布局中包装文本吗?,java,android,android-tablelayout,Java,Android,Android Tablelayout,由于某种原因,我在这方面遇到了麻烦。。。带有“name”的列不应该占用那么多空间。该列不包装文本。下面的设置是我一直在使用的,它以前已经工作过。我错过了什么?日食可能有什么问题吗 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

由于某种原因,我在这方面遇到了麻烦。。。带有“name”的列不应该占用那么多空间。该列不包装文本。下面的设置是我一直在使用的,它以前已经工作过。我错过了什么?日食可能有什么问题吗

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fadingEdgeLength="100dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#333333"
android:stretchColumns="*">
<TableRow android:layout_margin="1dp" android:background="#333333" android:gravity="center">
<TextView
android:gravity="center"
android:padding="3dip"
android:text="Friends"
android:textColor="#000000"
android:textSize="22dp" />
</TableRow>
<TableRow android:layout_margin="1dp" android:background="#000000">
<TextView
android:gravity="left"
android:padding="3dip"
android:text="Name"
android:textColor="#ffffff"
android:textSize="15dp" />
<TextView
android:gravity="left"
android:padding="3dip"
android:text="Address"
android:textColor="#66cccc"
android:textSize="15dp" />
<TextView
android:gravity="left"
android:padding="3dip"
android:text="Interests"
android:textColor="#006666"
android:textSize="15dp" />
</TableRow> 
<TableRow android:layout_margin="1dp" android:background="#000000">
<TextView
android:gravity="left"
android:padding="3dip"
android:text="This is short"
android:textColor="#ffffff"
android:textSize="13dp"
android:width="0dip"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<TextView
android:gravity="left"
android:padding="3dip"
android:text="This is some text that might be too long and might need to wrap to the next line."
android:textColor="#cc0033"
android:textSize="13dp"
android:width="0dip"
android:layout_height="match_parent"
android:background="#222222" />
<TextView
android:gravity="left"
android:padding="3dip"
android:text="This is some text that will be long so it needs to wrap and go to the next line blah blah blah."
android:textColor="#99cc00"
android:textSize="13dp"
android:width="0dip"
android:layout_height="match_parent" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>

来自:

TableRow的子级不需要在XML文件中指定布局宽度和布局高度属性。TableRow始终将这些值分别强制为MATCH_PARENT和WRAP_CONTENT

这可能会导致一些问题,尽管它的措辞向我建议,它无论如何都应该忽略您的设置,只是覆盖它们。尽管如此,还是有必要去掉
表格行中
文本视图中的
布局宽度
布局高度
属性,看看是否有帮助

更新:


刚刚注意到您已将
stretchColumns
设置为
*
。将其更改为
1,2

您是否尝试过在文本视图中缩小文本?我删除了所有布局高度和布局宽度属性,但仍在进行中,只是为
拉伸列添加了建议。谢谢!这使最后两列正常工作,但问题仍然是第一列(名称)没有被包装。它几乎占据了屏幕的1/3,而它应该只和输入的名称一样长。我将您的布局放在一个新项目中,删除了不必要的
layout\u width
layout\u height
属性,并将
stretchColumns
*
更改为
1,2
,我觉得很好。第一列的宽度刚好适合这个名字。谢谢。我复制了代码,删除了xml,重新创建了它,并再次粘贴了代码,它工作了。。。无法解释。。。