首页 > 解决方案 > 在 LinearLayout 中将 TableLayout 居中

问题描述

Android新手在这里。

<LinearLayout
    android:layout_below="@+id/mMainTop"
    android:layout_above="@+id/mMainBottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    // some TextView

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mSubTable"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center">

如何参考父级中剩余的空间TableLayout垂直居中?LinearLayout

我希望有人能理解我的意思。

标签: androidandroid-layout

解决方案


尝试android:layout_gravity="center"android:layout_gravity="center_vertical"您的 TableLayout 中制作

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mSubTable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical">

推荐阅读