【发布时间】:2015-10-14 16:12:01
【问题描述】:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Team A"
android:textSize="25sp" />
<!-- unable to place this 3 TextViews at center position of layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- make this as center -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="00"
android:textSize="70sp" />
<!-- make this as center -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textSize="70sp" />
<!-- make this as center -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="70sp" />
</LinearLayout>
【问题讨论】:
-
试试这个 android:layout_centerHorizontal="true"
-
取消添加这个标签。因为它是一个线性布局。 centerHorizontal 显示为无效属性
-
将
android:gravity="center"添加到您的内部线性布局中,这就是全部 -
@Yogesh ...我的回答有什么问题???
-
一切正常。抱歉,我现在看到了您的代码。
标签: android android-linearlayout center