<?xml version="1.0" encoding="utf-8"?>
<TableLayout
android:id="@+id/widget33"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="*"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow
android:id="@+id/widget34"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center" />
<TextView
android:id="@+id/widget36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center" />
<TextView
android:id="@+id/widget37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center" />
</TableRow>
</TableLayout>
The text in TextViews
is not aligned to the centre
even though the gravity
is set center
.Text is shifted to extreme right.When I check the same code in droidDraw every thing seems fine.Whats happening?
只要您为android:layout_width
和android:layout_height
使用wrap_content
,重力就不会做任何事情。
//尝试
android:layout_gravity="center"
If you set TextView to wrap_content it takes up as small space as posible. When you set it to center it centers inside the wrap_content. This makes it seem that there is no difference.
If you set TextView to fill or match_parent it will center inside the TableLayout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.