用了android的各种布局,发现每种布局的居中,对齐方式都不一样,需要自己屡次尝试,甚是苦恼
给同样在苦恼中的人晒下TableLayout居中的方式
这是一个即将被我充斥到另外一个
<ListView android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/detail">
</ListView>
里面去的Table,其实实现它的每单元格内容居中很简单,给它的上一级设置android:gravity="center"即可,还有个问题,需去掉下一级所有跟居中有关的属性
(之前没去掉,上级的属性都没生效了,奇怪?),代码如下:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout