Home > Blockchain >  android studio relativelayout
android studio relativelayout

Time:12-14

new to Android studio and Java. I am looking to use a relativelayout to produce this:- Layout required

For some reason can not get to work. If layout is change, ie rotated 90 degrees right. This giving the image along the top with the four buttons underneath it work. But can not get the image on the left with button on the right.

Please any help.

CodePudding user response:

Easy to produce that layout using LinearLayout than Relative, something like this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
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_height="match_parent"
   android:layout_width="match_parent"
   android:weightSum="2">
   <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:padding="20dp"
       android:layout_weight="1">
       <Button
           android:layout_width="wrap_content"
           android:layout_height="match_parent"
           android:layout_alignParentLeft="true"
           android:text="Image"
           android:layout_weight="1">
       </Button>
   </LinearLayout>
  
   <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:layout_weight="1"
       android:orientation="vertical"
       android:weightSum="4"
       android:padding="20dp">
       <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Button"
           android:layout_weight="1"></Button>
       <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Button"
           android:layout_weight="1"></Button>
       <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Button"
           android:layout_weight="1"></Button>
       <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Button"
           android:layout_weight="1"></Button>
   </LinearLayout>

  </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
  • Related