How to place buttons at the bottom of the screen in Android development



  • When the image image for animation is displayed at the top, the bottom button will turn right. I don't come to the center even if layour is centered. Programming is important, so please understand it. Please show your reference WED and code. F
    PS
    I don't know how to configure layout. However, in the current situation, the button can only be set to the right from the image ☆ (sun). (Figure 1) Figure 2

    activity_main.xml

    <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
     android:layout_width="match_parent"
     xmlns:tools="http://schemas.android.com/tools">
    

    <ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/sun"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="153dp"
    android:id="@+id/img"/>

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

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center"/>

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Butt1"
    android:layout_gravity="bottom"
    android:layout_weight="1"
    android:id="@+id/btn1" />
    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Butt2"
    android:layout_weight="1"
    android:layout_gravity="bottom"
    android:id="@+id/btn2" />

    </LinearLayout>

    res/anim/rotate.xml

    <rotate
    android:repeatCount="10"
    android:pivotX="10"
    android:pivotY="240"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:duration="500"
    />


  • QA Engineer

    What are the following layouts?

    <FrameLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
    &lt;ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/sun"
            android:layout_marginTop="10dp"
            android:layout_gravity="center_horizontal"
            android:id="@+id/img"/&gt;
    
    &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="center_horizontal|bottom"&gt;
    
        &lt;Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Butt1"
                android:id="@+id/btn1"/&gt;
        &lt;Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Butt2"
                android:id="@+id/btn2"/&gt;
    
    &lt;/LinearLayout&gt;
    

    </FrameLayout>

    FrameLayout Home LinearLayout About http://mixi-inc.github.io/AndroidTraining/fundamentals/2.01.create-layout.html Sorry, this entry is only available in 日本語.

    Click here for more information.
    https://developer.android.com/reference/android/widget/FrameLayout.html
    https://developer.android.com/reference/android/widget/LinearLayout.html


Log in to reply
 


Suggested Topics

  • 2
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 1
  • 2
  • 2