Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.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/0/xml/14.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
androidxml表布局_Android_Xml_Tablelayout - Fatal编程技术网

androidxml表布局

androidxml表布局,android,xml,tablelayout,Android,Xml,Tablelayout,因此,我尝试创建一个如下所示的表: shrimp: 12pc $10.99 24pc $18.99 scallops: 10pc $11.99 15pc $14.99 …等等 但是,我的代码有一些问题,它使第一列(例如shrimp)占据了大部分屏幕空间,而计数和价格最终被压扁在屏幕的右侧 <TableRow android:layout_width="wrap_content" android:layout_height="wrap_conte

因此,我尝试创建一个如下所示的表:

shrimp: 12pc $10.99   24pc $18.99

scallops: 10pc $11.99   15pc $14.99
…等等

但是,我的代码有一些问题,它使第一列(例如
shrimp
)占据了大部分屏幕空间,而计数和价格最终被压扁在屏幕的右侧

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

        <TextView
            android:layout_width="wrap_conent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Shrimp:" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="12pc - $10.99" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="24pc - $18.99" />
    </TableRow>


有人能告诉我这里出了什么问题吗?我试着在布局宽度和高度上做些调整,但我能让它看起来像我想要的那样的唯一方法是,如果我在第一列的布局宽度中键入了错误的内容。它看起来像我想要的那样,但是如果我这样做,我会得到一个编译器错误

这是因为布局权重属性,请尝试删除它,并在文本视图之间添加一些空间


然后它将是您所需要的。

所有文本视图:将
android:layout\u width=“wrap\u content”
更改为
android:layout\u width=“0dp”
这就是重量的工作方式。工作非常完美!非常感谢你。