Katherine
Katherine

Reputation: 1

How can i move my buttons lower in an Android studio? They stay on top , fixed

I want them to stay in the middle of the app but i can't move them. I assume is some constraint regarding the layout. This is the code, 3 simple buttons integrated in layouts. i want to know if there's any line code that would help me move them lower even if is button by button or all the block

<?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>

The layout

Upvotes: 0

Views: 147

Answers (1)

Nouran Samak
Nouran Samak

Reputation: 31

In the first LinearLayout, add 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>

Upvotes: 2

Related Questions