Android:集中式TableLayout?
请看一下这个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以..如果我以正确的方式理解你的问题...
this should do it.. if i have understood your problem in right manner...
用 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.