我想在运行时在中心显示我的用户屏幕。我正在使用表格布局。问题是屏幕始终在左侧显示我的用户屏幕。我已将布局的重力属性更改为中心。但它没有做任何改变。我想知道如何在屏幕中央显示我的用户屏幕(模拟器)。
最佳答案
要将表格对齐到页面中间,您可以使用
布局重力作为表格布局的中心以及
布局宽度和高度设置为换行内容表格,如下所示
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
关于android - 在android中使用表格布局时屏幕居中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5269785/