如何在中心對齊的相對佈局中放置兩個文本視圖Marked within red rectangle
。我如何設計如圖所示? 這裏的文本和數字都是textviews。如何以相對佈局爲中心對齊兩個文本視圖
我曾嘗試以下,但我不能讓中心對齊以相對佈局。
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp">
<LinearLayout
android:id="@+id/location_party_size_lbl_layer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="horizontal">
<TextView
android:id="@+id/location_party_size_lbl"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:maxLines="2"
android:text="@string/loc_estimate"
android:textColor="@android:color/white"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/location_party_size_lbl_layer"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:weightSum="1.0">
<TextView
android:id="@+id/location_party_size"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.48"
android:background="@drawable/rounded_bg"
android:gravity="center"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/qnowscreen_dummy_tv"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.52"
android:visibility="invisible" />
</LinearLayout>
</RelativeLayout>
也許你可以使用一個linearlayout的方向水平和權重的子女? – Bram
你可以從你的xml標籤中指出,哪兩個textiviews要中心對齊,如果你想讓它們垂直和水平居中對齊,就好像你有兩個,它們會重疊?你想如何將它們放在一起?從圖像中不清楚。 –
@ Ms YvetteǝʇʇǝʌʎsW,location_party_size_lbl用於顯示文本「估計....」和用於顯示「2」的location_party_size –