Как я могу переместить мои кнопки ниже в Android-студии? Они остаются на вершине, фиксированные - PullRequest
0 голосов
/ 10 января 2019

Я хочу, чтобы они оставались в середине приложения, но я не могу их переместить. Я предполагаю, что есть некоторые ограничения в отношении макета. Это код, 3 простые кнопки, встроенные в макеты. я хочу знать, есть ли какой-либо строчный код, который помог бы мне переместить их ниже, даже если бы кнопка за кнопкой или весь блок

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"> 



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingBottom="20dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">


        <Button
            android:id="@+id/b1"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"

            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:background="#f6f3e0"
            android:drawableLeft="@drawable/capitole"
            android:foreground="?attr/selectableItemBackground"
            android:padding-left
            android:text="Button1"
           android:textAppearance="@style/TextAppearance.AppCompat.Button"/>
    </LinearLayout>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button

            android:id="@+id/b2"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"

            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:background="#cbe8eb"
            android:drawableLeft="@drawable/random"
            android:foreground="?attr/selectableItemBackground"
            android:padding-left
            android:text="Random"
            android:textAppearance="@style/TextAppearance.AppCompat.Button" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button
            android:id="@+id/b3"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:background="@android:color/holo_orange_light"
            android:drawableLeft="@drawable/developer"
            android:foreground="?attr/selectableItemBackground"
            android:paddingDown="45dp"
            android:text="Developer"
            android:textAppearance="@style/TextAppearance.AppCompat.Button" />

    </LinearLayout>
</LinearLayout>

Макет

1 Ответ

0 голосов
/ 10 января 2019

В первом LinearLayout добавить android:layout_gravity="center"

<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="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:paddingBottom="20dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">


        <Button
            android:id="@+id/b1"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:background="#f6f3e0"
            android:drawableLeft="@drawable/capitole"
            android:foreground="?attr/selectableItemBackground"
            android:padding-left
            android:text="Button1"
            android:textAppearance="@style/TextAppearance.AppCompat.Button"/>
    </LinearLayout>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button

            android:id="@+id/b2"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"

            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:background="#cbe8eb"
            android:drawableLeft="@drawable/random"
            android:foreground="?attr/selectableItemBackground"
            android:padding-left
            android:text="Random"
            android:textAppearance="@style/TextAppearance.AppCompat.Button" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button
            android:id="@+id/b3"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_margin="2dp"
            android:background="@android:color/holo_orange_light"
            android:drawableLeft="@drawable/developer"
            android:foreground="?attr/selectableItemBackground"
            android:paddingDown="45dp"
            android:text="Developer"
            android:textAppearance="@style/TextAppearance.AppCompat.Button" />

    </LinearLayout>
</LinearLayout>
...