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”
这就是重量的工作方式。工作非常完美!非常感谢你。