我如下三個按鈕放置,線性佈局水平,重力問題
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Standard"
android:id="@+id/standard_map"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="satellite"
android:id="@+id/satellite"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hybrid"
android:id="@+id/hybrid"/>
</LinearLayout>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
map:cameraTargetLat="13.0827"
map:cameraTargetLng="80.2707"
map:cameraBearing="112.5"
map:cameraTilt="65"
map:cameraZoom="20"/>
</LinearLayout>
輸出收率如下: image explaining the problem
內線性佈局的取向是水平的,並且是完全精細。我需要按鈕在中心對齊(垂直居中)。即使當我使用android:gravity="centre"
時,它也會將水平居中的按鈕對齊,這是無用的。 我需要按鈕在水平線性佈局中垂直居中。
謝謝..它的空間了等於..而且似乎集中..幹得好。 。 –