从其他活动访问回来时,Android TextView未居中对齐?
好吧,我有一个非常奇怪的问题,我以前从未面对过。所以我有一个表格布局,里面有两列。以下是首次启动活动的结果: 导航到其他活动并返回此活动后,结果如下: 这是我的密码:从其他活动访问回来时,Android TextView未居中对齐?,android,Android,好吧,我有一个非常奇怪的问题,我以前从未面对过。所以我有一个表格布局,里面有两列。以下是首次启动活动的结果: 导航到其他活动并返回此活动后,结果如下: 这是我的密码: <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <TableRow
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:background="#FF4545"
android:layout_weight="1"
android:padding="10dp"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1.1" />
</LinearLayout>
<LinearLayout
android:background="#70FF42"
android:layout_weight="1"
android:padding="10dp"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="2.1" />
</LinearLayout>
</TableRow>
</TableLayout>
有人能告诉我我的代码有什么问题吗?更新了您的布局,看看它是否适合您
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FF4545"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="1.1" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#70FF42"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="2.1" />
</LinearLayout>
</TableRow>
</TableLayout>
您应该确保表格布局在线性布局中,并且能够正确显示
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout>
</TableLayout>
</LinearLayout>
这是一个这样的例子