我如下三个按钮放置,线性布局水平,重力问题
<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"
时,它也会将水平居中的按钮对齐,这是无用的。 我需要按钮在水平线性布局中垂直居中。
谢谢..它的空间了等于..而且似乎集中..干得好。 。 –