2013-12-09 199 views
0

我有一个正确居中的TextView,但是当我想居中表格的内容时,如果没有对齐到居中。我试图将TableLayout的内容与中心对齐

layout_gravity="center" 

gravity="center" 

两者都不能正常工作。我能做什么?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <TextView 
     android:id="@+id/date" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:padding="20dp" /> 
    <TableLayout 
     android:id="@+id/table" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/date" /> 
</RelativeLayout> 
+0

你在'TableLayout'本身或表中的元素上试过了吗? – Szymon

+0

TableLayout本身。我编程创建TableRows – Nfear

+0

尝试将它们居中。 – Szymon

回答

0

不确定精确的输出你是从布局的期待,但你可以尝试设置表格的宽度“WRAP_CONTENT”和使用属性的android:layout_centerInParent =“true”或机器人:layout_centerHorizo​​ntal =“真“或android:layout_centerVertical =”true“在TableLayout上。

我希望这会有所帮助。