Android:集中式TableLayout?

发布于 2024-11-17 20:01:56 字数 813 浏览 10 评论 0原文

请看一下这个 XML 代码:

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:isScrollContainer="true"
    android:scrollbarStyle="outsideInset">

    <TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    >
        <ImageButton
        <!-- Some Code -->
        />
        <ImageButton
        <!-- Some Code -->
        />
        <ImageButton
        <!-- Some Code -->
        />
    </TableRow>
</TableLayout>

三个 ImageButtons 在我的设备中显示良好(完全集中)。但是,当我在另一台屏幕较大的设备上测试该应用程序时,这三个图像似乎左对齐。

有没有办法让布局集中化?不管屏幕宽度是多少?

Please take a look at this XML code:

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:isScrollContainer="true"
    android:scrollbarStyle="outsideInset">

    <TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    >
        <ImageButton
        <!-- Some Code -->
        />
        <ImageButton
        <!-- Some Code -->
        />
        <ImageButton
        <!-- Some Code -->
        />
    </TableRow>
</TableLayout>

The three ImageButtons are displayed fine in my device (Centralized exactly). However, when I test the app in another device with larger screen, the three images seems to be aligned to the left.

Is there a way to make the layout centralized? No matter what the screen width is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何其悲哀 2024-11-24 20:01:56

这应该可以..如果我以正确的方式理解你的问题...

 <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dip"
        android:isScrollContainer="true"
        android:scrollbarStyle="outsideInset"
        android:gravity="center_Horizontal|Center_Vertical">
 <TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_Horizontal|Center_Vertical"
>

this should do it.. if i have understood your problem in right manner...

 <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dip"
        android:isScrollContainer="true"
        android:scrollbarStyle="outsideInset"
        android:gravity="center_Horizontal|Center_Vertical">
 <TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_Horizontal|Center_Vertical"
>
累赘 2024-11-24 20:01:56

用 Linearlayout 以类似的格式包装每个图像按钮。将每个线性布局的重力设置为中心。对于所有线性布局,布局宽度 = fill_parent。

wrap with linearlayout every image button in similar format . set gravity for each linearlayout to be center. and layout width = fill_parent for all linearlayouts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文