简体   繁体   English

如何使控件在表格布局中右对齐?

[英]How to make control right aligned in table layout?

I am using table layout for my Android application.我正在为我的 Android 应用程序使用表格布局。 I have a row with two elements and I'd like second element was right aligned.我有一排有两个元素,我希望第二个元素右对齐。 Even if I use gravity="right", it still looks like left aligned.即使我使用gravity="right",它仍然看起来像左对齐。 I can image that problem is that table cell doesn't get full width to the rest of the screen.我可以想象这个问题是表格单元格没有得到屏幕的 rest 的全宽。 However I do not see how I can control that.但是,我不知道如何控制它。

Why don't you try using layout_gravity="right" instead?你为什么不尝试使用 layout_gravity="right" 呢? And for filling the width for the screen, set the layout_width of the tablelayout to "fill_parent" and try using android:stretchColumns="*"为了填充屏幕的宽度,将表格布局的 layout_width 设置为“fill_parent”并尝试使用 android:stretchColumns="*"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM