Ich habe 4 Bild-Tasten, und später mehr hinzufügen. Ich möchte sie einzeln hinzufügen und jeder ist unter dem vorherigen. Daher habe ich ein ScrollView
erstellt, so dass es scrollbar ist, alle Schaltflächen anzuzeigen. Aber nachdem ich die ScrollView
hinzugefügt habe, kann ich andere Elemente nicht verschieben.Android Bild ausrichten Taste eins nach dem anderen und scrollbar
Hier ist mein Codes:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.exampl.mygames.MainActivity$PlaceholderFragment">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/btntower"
android:id="@+id/imageButton"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:cropToPadding="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/btntower"
android:id="@+id/imageButton2"
android:layout_alignBottom="@+id/imageButton"
android:scaleType="fitXY"
android:layout_marginTop="20dip"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:cropToPadding="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/btntower"
android:id="@+id/imageButton3"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:cropToPadding="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/btntower"
android:id="@+id/imageButton4"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:cropToPadding="false"/>
</RelativeLayout>
</ScrollView>
ändern, wenn sie hintereinander auszurichten, verwenden Sie ein Linearlayout und 'android: gravity =" center "' auf den imageButtons – Zoe