android 设置每列的文字对齐
时间: 2023-11-12 20:05:11 浏览: 79
可以使用以下属性来设置每列的文字对齐方式:
1. gravity:设置列的整体对齐方式,可选值为left、right、center等。
2. layout_gravity:设置列内的文字对齐方式,可选值为left、right、center等。
例如,以下代码将第一列文字左对齐,第二列文字居中对齐,第三列文字右对齐:
```
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:text="Left Align"
android:gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Center Align"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Right Align"
android:gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
```
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![.zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)