Why aren't my buttons aligning horizontally in Android Studio xml? - java

I want to change alignment of my button horizontally.
This is my xml code on Android Studio:
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="topClick"
android:text="Button"
app:layout_constraintTop_toBottomOf="#+id/textView"
tools:layout_editor_absoluteX="161dp" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="bottomClick"
android:text="Button"
app:layout_constraintTop_toBottomOf="#+id/button"
tools:layout_editor_absoluteX="161dp" />
*It even looks fine on the design panel:
But when I run it on my phone it turns out like this:

It's because you're using tools:layout_editor_absoluteX="161dp" to set the button position in the preview. This won't be applied to the actual app (tool attributes will be removed when the apk is built).
Instead set up the constraints for the buttons as you require, something along the following lines should work,
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="topClick"
android:text="Button"
app:layout_constraintTop_toBottomOf="#+id/textView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="bottomClick"
android:text="Button"
app:layout_constraintTop_toBottomOf="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />

You should have always have all the four constraints defined.
Try using vertical and horizontal bias.
And don't use tools:layout_editor_absoluteX="161dp"
Try this code:
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toStartOf="parent"
app:layout_constraintRight_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="topClick"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.65" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="bottomClick"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />

Follow this code
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="317dp" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="#+id/textView6"
app:layout_constraintStart_toStartOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView6" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="#+id/button"
app:layout_constraintStart_toStartOf="#+id/button"
app:layout_constraintTop_toBottomOf="#+id/button" />

<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.65" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />
</androidx.constraintlayout.widget.ConstraintLayout>

Related

Multiples imagesView with text in a ScrollView

I'm making a soundbox for me and my friends in android studio.
I've got a simple Scroll view, that I filled up with multiple constraintLayout that each contains 2 imageView with each of having a line of text under it.
The problem is that when I run the app, I only see the 2 first layouts, i've no idea what's going on and this is probably not the good way to do it.
What's the best solution here? Here is the xml code :
<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:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="800dp"
android:background="#353535"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/buttonStopAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/red_perso"
android:text="Stop tout"
android:textColor="#000000" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/idTheoGonfle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/theosouffle" />
<ImageView
android:id="#+id/idChuteCJ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/cjchute" />
<TextView
android:id="#+id/textTheoGonfle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:background="#FFEB3B"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="Théo gonfle"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/idTheoGonfle" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:background="#FFEB3B"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/idChuteCJ" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout4"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_launcher_foreground" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_launcher_foreground" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout3"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout2"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
<ImageView
android:id="#+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>```
look like you are begginer.
<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:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="800dp"
android:background="#353535"
tools:context=".MainActivity">
look like your problem
android:layout_height="800dp"
You set the fix height. Change it to match_parent.
<androidx.constraintlayout.widget.ConstraintLayout. And change root layout to FrameLayout or remove it.

RecyclerView not scrolling inside NestedScrollView

I'm designing a complex UI that has a NestedScrollView as a parent and inside it, there is a RecyclerView. Now the problem is that I'm not able to scroll the items inside the RecyclerView.
Things I've tried
Replacing ScrollView with NestedScrollView
Enabling android:fillViewport="true"
Disabling NestedScrolling of RecyclerView
<?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=".screens.StudentPreview">
<androidx.cardview.widget.CardView
android:id="#+id/toolbarCV"
android:layout_width="match_parent"
android:layout_height="130dp"
android:translationY="-45dp"
app:cardCornerRadius="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1641A2">
<ImageView
android:id="#+id/menuIV"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:src="#drawable/ic_home"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.7" />
<TextView
android:id="#+id/featureName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:fontFamily="#font/poppins_light"
android:text="Student Preview"
android:textColor="#fff"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.75" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.core.widget.NestedScrollView
android:id="#+id/studentPreviewNSV"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="90dp"
android:fillViewport="true"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/avatarCV"
android:layout_width="60dp"
android:layout_height="60dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="40dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="#+id/studentDetailsCL"
app:layout_constraintEnd_toStartOf="#+id/studentDetailsCL"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/studentDetailsCL">
<ImageView
android:id="#+id/avatarIV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="gone"
tools:src="#drawable/avatar_sample" />
<TextView
android:id="#+id/nameInitialTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/montserrat"
android:textColor="#FFF"
android:textSize="24sp"
android:textStyle="bold"
android:visibility="gone"
tools:text="AK"
tools:visibility="visible" />
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/studentDetailsCL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/avatarCV"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/studentNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Akrit Khanna" />
<TextView
android:id="#+id/classNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat"
android:textColor="#000"
android:textSize="15sp"
app:layout_constraintStart_toStartOf="#+id/studentNameTV"
app:layout_constraintTop_toBottomOf="#+id/studentNameTV"
tools:text="Class 8th A" />
<TextView
android:id="#+id/lastLoggedTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="#+id/classNameTV"
app:layout_constraintTop_toBottomOf="#+id/classNameTV"
tools:text="Last Logged: 30-01-2020" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id="#+id/classEnrollCV"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
app:cardBackgroundColor="#F5F5F5"
app:cardCornerRadius="18dp"
app:cardElevation="3dp"
app:layout_constraintEnd_toStartOf="#+id/courseEnrollCV"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/detailsGL">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/classEnrollCountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/classEnrollTVContainerFL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1" />
<FrameLayout
android:id="#+id/classEnrollTVContainerFL"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#D0D9EC"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/raleway"
android:text="Classes Enrolled"
android:textColor="#1641A2"
android:textSize="18sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/courseEnrollCV"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#F5F5F5"
app:cardCornerRadius="18dp"
app:cardElevation="3dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/classEnrollCV"
app:layout_constraintTop_toTopOf="#+id/detailsGL">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/courseEnrollCountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/courseEnrollTVContainerFL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1" />
<FrameLayout
android:id="#+id/courseEnrollTVContainerFL"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#D0D9EC"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/raleway"
android:text="Courses Enrolled"
android:textColor="#1641A2"
android:textSize="18sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/detailsGL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="90dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/reportCL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#F5F5F5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/classEnrollCV">
<Spinner
android:id="#+id/classOrTermSpinner"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="#+id/courseSpinner"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/courseSpinner"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/classOrTermSpinner"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reportRV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/courseSpinner" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Use a NestedScrolView and add this to your RecyclerView:
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setHasFixedSize(false);
Or this to the XML:
android:nestedScrollingEnabled="false"
Also it might help to add orientation to the recyclerView:
android:orientation="vertical"
Wrap all the views present inside NestedScrollView into a RelativeLayout. For ex,
<androidx.core.widget.NestedScrollView
android:id="#+id/studentPreviewNSV"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="90dp"
android:fillViewport="true"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- your remaining code -->
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
I managed to fix this problem by adding android:layout_marginBottom="100dp"
I think this was happening because I gave android:layout_marginTop="90dp" to my NestedScrollView and due to that RecyclerView was assuming that all the items are visible on the screen so there is no need for scrolling. (Correct me if I'm wrong)
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reportRV"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/courseSpinner"
tools:listitem="#layout/report_list_layout"
android:orientation="vertical"
android:layout_marginBottom="100dp"/>

Static buttons over top a scroll view android studio

I want to create an activity where i have 2 buttons at the bottom of the screen, and a scroll view above them. Inside of the scroll view i want a drop down menu where the user can select a series of exercises. How do I put the scroll view above the buttons and have them stay in the same spot when scrolling?
Code for activity
<?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:id="#+id/ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WorkoutsCreater">
<TextView
android:id="#+id/NameWorkoutTextView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:gravity="center"
android:text="Name of Workout:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:textSize="15dp"
app:layout_constraintBottom_toBottomOf="#+id/NameWorkoutInput"
app:layout_constraintEnd_toStartOf="#+id/NameWorkoutInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/NameWorkoutInput" />
<TextView
android:id="#+id/nameExercise1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:gravity="center"
android:text="Exercise 1:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:textSize="15dp"
app:layout_constraintBottom_toBottomOf="#id/spinnerExercise1"
app:layout_constraintEnd_toStartOf="#+id/NameWorkoutInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/spinnerExercise1" />
<EditText
android:id="#+id/NameWorkoutInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:inputType="text"
android:maxLength="20"
android:textSize="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/NameWorkoutTextView"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/BtnNew"
android:layout_width="77dp"
android:layout_height="77dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/circle_plus"
android:clickable="true"
android:focusable="true"
android:foreground="#drawable/ic_add_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="#drawable/ic_add_white" />
<Button
android:id="#+id/BtnSave"
android:layout_width="77dp"
android:layout_height="77dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/rounded_corners"
android:foreground="#drawable/ic_save_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="#+id/spinnerExercise1"
android:layout_width="175dp"
android:layout_height="43dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/NameWorkoutInput" />
Image of activity
If you want to add a scrollview that stays above the two buttons, you can add a NestedScrollview inside the constraintlayout
<?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:id="#+id/ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WorkoutsCreater">
<androidx.core.widget.NestedScrollView
android:layout_width="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="#id/BtnNew"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/NameWorkoutTextView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:gravity="center"
android:text="Name of Workout:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:textSize="15dp"
app:layout_constraintBottom_toBottomOf="#+id/NameWorkoutInput"
app:layout_constraintEnd_toStartOf="#+id/NameWorkoutInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/NameWorkoutInput" />
<TextView
android:id="#+id/nameExercise1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:gravity="center"
android:text="Exercise 1:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:textSize="15dp"
app:layout_constraintBottom_toBottomOf="#id/spinnerExercise1"
app:layout_constraintEnd_toStartOf="#+id/NameWorkoutInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/spinnerExercise1" />
<EditText
android:id="#+id/NameWorkoutInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:inputType="text"
android:maxLength="20"
android:textSize="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/NameWorkoutTextView"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/spinnerExercise1"
android:layout_width="175dp"
android:layout_height="43dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/NameWorkoutInput" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="#+id/BtnNew"
android:layout_width="77dp"
android:layout_height="77dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/ic_add_circle"
android:clickable="true"
android:focusable="true"
android:foreground="#drawable/ic_add_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="#drawable/ic_add_white" />
<Button
android:id="#+id/BtnSave"
android:layout_width="77dp"
android:layout_height="77dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/ic_remove_red_ba0a00"
android:foreground="#drawable/ic_save_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Disclaimer: Nested layouts are more costlier than flat layouts
Please have a look at this https://developer.android.com/topic/performance/rendering/optimizing-view-hierarchies

Android Studio Layout is Compressed

I have a problem. Everything just looks compressed but my design layout in my IDE is normal as is. What could be the problem?
First pic: The output of the app. Everything is compressed. I have no idea what happened
Second pic: Everything seems normal
This is my XML Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/activity_main">
<android.support.constraint.ConstraintLayout
android:layout_width="395dp"
android:layout_height="659dp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<Button
android:id="#+id/btn_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_text"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="131dp" />
<Button
android:id="#+id/btn_txt_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#android:drawable/ic_dialog_email"
android:text="#string/btn_txt_image"
tools:layout_editor_absoluteX="117dp"
tools:layout_editor_absoluteY="131dp" />
<ImageButton
android:id="#+id/ibtn_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="TODO"
android:onClick="doImageButton"
app:srcCompat="#android:drawable/ic_menu_camera"
tools:layout_editor_absoluteX="237dp"
tools:layout_editor_absoluteY="128dp" />
<CheckBox
android:id="#+id/cbx_fruit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cbx_fruit"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="221dp" />
<CheckBox
android:id="#+id/cbx_meat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cbx_meat"
tools:layout_editor_absoluteX="135dp"
tools:layout_editor_absoluteY="221dp" />
<RadioGroup
android:id="#+id/rgrp_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="283dp">
<RadioButton
android:id="#+id/rbtn_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rbtn_one" />
<RadioButton
android:id="#+id/rbtn_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rbtn_two" />
<RadioButton
android:id="#+id/rbtn_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rbtn_three" />
</RadioGroup>
<RatingBar
android:id="#+id/rbar_star"
android:layout_width="435dp"
android:layout_height="116dp"
tools:layout_editor_absoluteX="-37dp"
tools:layout_editor_absoluteY="454dp" />
<EditText
android:id="#+id/etxt_msg"
android:layout_width="251dp"
android:layout_height="55dp"
android:ems="10"
android:inputType="textPersonName"
android:text="#string/etxt_msg"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="606dp" />
<Button
android:id="#+id/btn_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_toast"
tools:layout_editor_absoluteX="293dp"
tools:layout_editor_absoluteY="612dp" />
<ToggleButton
android:id="#+id/tbtn_power"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tbtn_power"
tools:layout_editor_absoluteX="279dp"
tools:layout_editor_absoluteY="312dp" />
</android.support.constraint.ConstraintLayout>
You need to add constraints to your layout views, heres an example:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/constraintlayout_intro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:paddingLeft="#dimen/spacing_normal"
android:paddingRight="#dimen/spacing_normal">
<br.com.informant.cegonheira.ui.component.CustomViewPager
android:id="#+id/viewpager_intro"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_intro"
android:layout_width="200dp"
android:layout_marginTop="360dp"
android:layout_height="#dimen/spacing_big"
android:background="#drawable/background_rounded_green_gradient_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<me.relex.circleindicator.CircleIndicator
android:id="#+id/circle_indicator_intro"
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_normal"
android:layout_marginTop="460dp"
app:ci_drawable="#drawable/ic_radio_white"
app:ci_drawable_unselected="#drawable/ic_radio_grey"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Notice this in the last view(CircleIndicator):
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
This is what tells where the view is going to be "anchored", otherwise they just "float" like happened to yours.
You can read more about it here: Build a Responsive UI with ConstraintLayout
Congratulations for your first app!

Android Studio Linear Layout Design issue

I am having an issue with designing Android Studio Layout for App. In linear layout, I want to add first two layouts in the first column horizontally and then in the next column, I wish to add that three buttons in horizontally and finally in the last column want to add Listview. Any help would be highly appreciated. As currently, everything falls into one row.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<james.view.VideoView
android:id="#+id/remoteVideoView"
android:layout_width="120dp"
android:layout_height="90dp"
/>
<james.view.VideoView
android:id="#+id/localVideoView"
android:layout_width="120dp"
android:layout_height="90dp"
/>
<Button
android:id="#+id/startVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Call"
/>
<Button
android:id="#+id/stopVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="End Call"
/>
<Button
android:id="#+id/sendmessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="msg"
/>
<ListView
android:id="#+id/errorList"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
</android.support.constraint.ConstraintLayou
This is how I want my layout to be
If you don't understand Constraints. You can use regular LinearLayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
>
<james.view.VideoView
android:id="#+id/remoteVideoView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<james.view.VideoView
android:id="#+id/localVideoView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<Button
android:id="#+id/startVideoButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Start Call"/>
<Button
android:id="#+id/stopVideoButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="End Call"/>
<Button
android:id="#+id/sendmessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="msg"/>
</LinearLayout>
<ListView
android:id="#+id/errorList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
>
</ListView>
</LinearLayout>
Quite simple!
Solution:
This is exactly how you want, Just copy paste and your job is done:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<james.view.VideoView
android:id="#+id/remoteVideoView"
android:layout_width="120dp"
android:layout_height="90dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/localVideoView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<james.view.VideoView
android:id="#+id/localVideoView"
android:layout_width="120dp"
android:layout_height="90dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/remoteVideoView"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout2">
<Button
android:id="#+id/startVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Start Call" />
<Button
android:id="#+id/stopVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="End Call" />
<Button
android:id="#+id/sendmessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="msg" />
</LinearLayout>
<ListView
android:id="#+id/errorList"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout3">
</ListView>
</android.support.constraint.ConstraintLayout>
Try it. Hope it helps.
This is a sample xml, similar to your image. Since your code uses constraintLayout I have created the xml using constraintLayout instead of linear layout. I have created this from the design screen and not from the text screen. This is the xml `
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="49dp"
android:layout_marginStart="49dp"
android:layout_marginTop="32dp"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="67dp"
android:layout_marginRight="67dp"
android:layout_marginTop="32dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="193dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="#+id/button"
app:layout_constraintStart_toStartOf="#+id/button"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:text="Button"
app:layout_constraintBaseline_toBaselineOf="#+id/button3"
app:layout_constraintStart_toEndOf="#+id/button3" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="35dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:layout_marginTop="193dp"
android:text="Button"
app:layout_constraintBottom_toTopOf="#+id/recyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="19dp"
android:layout_marginEnd="22dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginStart="22dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button5" />
</android.support.constraint.ConstraintLayout>
`
Please see if this helps you. This is not exact screen as per your requirements.

Categories

Resources