Ich versuche, eine Art von Bildergalerie mit einem HorizontalScrollView
erstellen. Ich möchte eine Taste vertikal zentriert haben, aber selbst wenn ich die gravity
als center_vertical
in meiner Taste angeben, gibt es keine Möglichkeit, es funktioniert, da es immer an der Spitze bleibt. Hier ist mein Layout:Android - Zentrierung Button in einem HorizontalScrollView
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<LinearLayout
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/horizontal_scroll_view"
android:layout_width="match_parent"
android:layout_height="@dimen/cameraPlaceholderHeight">
<LinearLayout
android:id="@+id/horizontal_scroll_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/greyBackgroundColor"
android:gravity="start|center_vertical"
android:orientation="horizontal">
<Button
android:id="@+id/camera_button"
android:layout_width="@dimen/take_picture_size"
android:layout_height="@dimen/take_picture_size"
android:layout_gravity="center_vertical"
android:background="@drawable/take_picture_rounded_button"
android:gravity="center_vertical"
android:src="@drawable/syi_camera_active"/>
</LinearLayout>
</HorizontalScrollView>
Vielen Dank im Voraus!
Stellen Sie die Höhe Ihres linearen Layouts auf match_parent –
Vielen Dank, mein Schlechter! – noloman