Keyboard resizing cuts a part of a button - android

I have a constraint layout inside a scroll view, with "adjustResize" in AndroidManifest.xml, because i want my views to resize when the user taps on an edit text. The problem is that sometimes (almost randomly) when I tap on the edit text (so the keyboard opens) or when i exit from the keyboard (pressing back button) the button is cut. This is what happens:
This is my layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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="wrap_content"
android:paddingBottom="50dp">
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:ems="10"
android:inputType="textPersonName"
android:theme="#style/EditTextStyleSendFunds"
app:layout_constraintEnd_toStartOf="#+id/imageView2"
app:layout_constraintHorizontal_bias="0.056"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:ems="10"
android:inputType="textPersonName"
android:theme="#style/EditTextStyleSendFunds"
app:layout_constraintEnd_toEndOf="#+id/editText3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText3" />
<EditText
android:id="#+id/editText3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:ems="10"
android:inputType="textPersonName"
android:theme="#style/EditTextStyleSendFunds"
app:layout_constraintEnd_toStartOf="#+id/button"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="31dp"
android:layout_height="35dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="32dp"
app:layout_constraintEnd_toEndOf="#+id/spinner2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/ic_qrcode_grey600_24dp" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:background="#android:color/transparent"
android:textAllCaps="false"
android:textColor="#color/colorPrimary"
app:layout_constraintEnd_toStartOf="#+id/spinner2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/editText3"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<Spinner
android:id="#+id/spinner"
android:layout_width="68dp"
android:layout_height="27dp"
android:layout_marginTop="48dp"
app:layout_constraintEnd_toEndOf="#+id/spinner2"
app:layout_constraintTop_toBottomOf="#+id/editText3" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="68dp"
android:layout_height="27dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="48dp"
android:theme="#style/SpinnerSendFunds"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/button"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:theme="#style/SpinnerSendFunds"
app:layout_constraintBottom_toBottomOf="#+id/editText5"
app:layout_constraintEnd_toEndOf="#+id/spinner"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#+id/editText5" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginTop="32dp"
app:layout_constraintStart_toStartOf="#+id/editText4"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:srcCompat="#drawable/add" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="32dp"
android:background="#drawable/buttons2"
android:text="SEND"
android:textColor="#android:color/white"
app:layout_constraintEnd_toEndOf="#+id/spinner5"
app:layout_constraintTop_toBottomOf="#+id/spinner5" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:text="Add Additional Data"
android:textColor="#color/colorPrimary"
app:layout_constraintStart_toEndOf="#+id/imageView3"
app:layout_constraintTop_toBottomOf="#+id/editText4" />
<EditText
android:id="#+id/editText4"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="number"
android:theme="#style/EditTextStyleSendFunds"
app:layout_constraintEnd_toEndOf="#+id/textView6"
app:layout_constraintStart_toStartOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView6" />
<EditText
android:id="#+id/editText5"
android:layout_width="113dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="numberDecimal"
android:theme="#style/EditTextStyleSendFunds"
app:layout_constraintEnd_toEndOf="#+id/textView7"
app:layout_constraintStart_toStartOf="#+id/textView7"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
<TextView
android:id="#+id/textView6"
android:layout_width="110dp"
android:layout_height="20dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
app:layout_constraintStart_toStartOf="#+id/editText2"
app:layout_constraintTop_toBottomOf="#+id/editText2" />
<TextView
android:id="#+id/textView7"
android:layout_width="110dp"
android:layout_height="20dp"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
app:layout_constraintStart_toEndOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/editText2" />
</android.support.constraint.ConstraintLayout>
</ScrollView>

Related

Android Studio Layout Design disappeared

!!Solved!!
Designed Layout not showing
When I am designing my project design layout disappeared, also the component tree shows "Nothing to Show". But Code is Still there and it's already running through an emulator. I restarted my laptop, close and reopened the project. but the problem is the same. what can I do?
this is my 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: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:layout_marginStart="32dp"
android:layout_marginTop="32dp"
android:text="#string/txtTopic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:text="#string/txtMsg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputTopic" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:text="#string/txtDate"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputMsg" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:text="#string/txtClass"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputTime" />
<Button
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="52dp"
android:backgroundTint="#color/DarkOrange"
android:text="#string/btnAdd"
app:cornerRadius="#dimen/btnCorner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputClass" />
<EditText
android:id="#+id/inputTopic"
android:layout_width="351dp"
android:layout_height="55dp"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:background="#drawable/edit_text_rounded_corner"
android:ems="10"
android:hint="#string/inputTopic"
android:inputType="textPersonName"
android:minHeight="48dp"
android:textColor="#color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView"
android:autofillHints="" />
<EditText
android:id="#+id/inputMsg"
android:layout_width="348dp"
android:layout_height="135dp"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:background="#drawable/edit_text_rounded_corner"
android:ems="10"
android:gravity="start|top"
android:hint="#string/inputMsg"
android:inputType="textMultiLine"
android:minHeight="48dp"
android:textColor="#color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.507"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView2"
android:autofillHints="" />
<EditText
android:id="#+id/inputDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:background="#drawable/edit_text_rounded_corner"
android:ems="10"
android:hint="#string/inputDate"
android:inputType="date"
android:minHeight="48dp"
android:textColor="#color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView3"
android:autofillHints="" />
<EditText
android:id="#+id/inputTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:background="#drawable/edit_text_rounded_corner"
android:ems="10"
android:hint="#string/inputTime"
android:inputType="time"
android:minHeight="48dp"
android:textColor="#color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6"
android:autofillHints="" />
<Spinner
android:id="#+id/inputClass"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:background="#drawable/edit_text_rounded_corner"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView5" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:text="#string/txtTime"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputDate" />
</androidx.constraintlayout.widget.ConstraintLayout>```

Difficulties Pertaining to Catering to Multiple Phone Screen Sizes

I am currently working on an application and am trying to allow it to support multiple phone screen sizes (it will not support anything larger than a Google Pixel 3 XL). Also, just for context, I'm using a ConstraintLayout.
For the background of the layout I'm using an image. On top of the background, I have interact-able elements meticulously placed to match the position they're supposed to correspond with on the background. This, however, doesn't translate well across all displays, as the layout elements and the background become distorted and misaligned. My solution to this was to try to make different layouts for phones which would be applied based on their resolution (layouts were made for phones with these screen dimensions: 1080x1920, 1080x2160, 1440x2560, 1440x2880, 1440x2960).
However, these don't seem to auto-apply to any of the devices I've tested on. I'm assuming this is because phones don't have any specifications and this only really applies to tablets, watches, etc. I just recently thought of transferring everything from my UI into my layout and to just implement everything using ImageViews, but this doesn't work either, since when the phone
screen size changes, all elements lose their proper placement within the screen. I've tried almost everything and can't quite think of anything else to do in order to make my app cater to all screen sizes.
I'll provide one of my more complicated layouts for reference. Really hoping for some help on this one. Thanks!
Layout
<?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"
android:orientation="vertical"
android:background="#drawable/a1440x2960_tt">
<TextView
android:id="#+id/display"
android:layout_width="wrap_content"
android:layout_height="74dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="152dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:fontFamily="#font/freesansbold"
android:text="00 : 00 . 00"
android:textColor="#color/black"
android:textSize="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/resetbtn"
android:layout_width="83dp"
android:layout_height="34dp"
android:layout_marginStart="268dp"
android:layout_marginLeft="268dp"
android:layout_marginTop="264dp"
android:background="#color/transparent"
android:stateListAnimator="#null"
android:textAllCaps="false"
android:textColor="#color/stopbtn"
android:textSize="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/pausebtn"
android:layout_width="92dp"
android:layout_height="35dp"
android:layout_marginStart="156dp"
android:layout_marginLeft="156dp"
android:layout_marginTop="264dp"
android:background="#color/transparent"
android:stateListAnimator="#null"
android:textAllCaps="false"
android:textColor="#color/stopbtn"
android:textSize="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/goalMinutes"
android:layout_width="96dp"
android:layout_height="66dp"
android:layout_marginStart="48dp"
android:layout_marginLeft="48dp"
android:layout_marginTop="156dp"
android:background="#null"
android:fontFamily="#font/freesansbold"
android:inputType="numberPassword"
android:text="00"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50dp"
app:layout_constraintStart_toStartOf="#+id/splashdebugoutput"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/goalMilli"
android:layout_width="93dp"
android:layout_height="66dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="156dp"
android:background="#null"
android:fontFamily="#font/freesansbold"
android:inputType="numberPassword"
android:text="00"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50dp"
app:layout_constraintStart_toStartOf="#+id/goal_dot"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/goalSeconds"
android:layout_width="82dp"
android:layout_height="66dp"
android:layout_marginTop="156dp"
android:background="#null"
android:fontFamily="#font/freesansbold"
android:inputType="numberPassword"
android:text="00"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50dp"
app:layout_constraintStart_toEndOf="#+id/goal_colon2"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/goal_dot"
android:layout_width="16dp"
android:layout_height="67dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="156dp"
android:fontFamily="#font/product_bold"
android:text="."
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50dp"
app:layout_constraintStart_toEndOf="#+id/goalSeconds"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/goal_colon"
android:layout_width="18dp"
android:layout_height="43dp"
android:layout_marginStart="28dp"
android:layout_marginLeft="28dp"
android:layout_marginTop="457dp"
android:fontFamily="#font/product_bold"
android:text=":"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="24dp"
app:layout_constraintStart_toStartOf="#+id/tempoSeconds"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/goal_colon2"
android:layout_width="16dp"
android:layout_height="67dp"
android:layout_marginTop="152dp"
android:fontFamily="#font/product_bold"
android:text=":"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50dp"
app:layout_constraintStart_toEndOf="#+id/goalMinutes"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/minmarker"
android:layout_width="15dp"
android:layout_height="21dp"
android:layout_marginStart="42dp"
android:layout_marginLeft="42dp"
android:layout_marginTop="64dp"
android:fontFamily="#font/product_regular"
android:text="M"
android:textColor="#color/black"
android:textSize="17dp"
app:layout_constraintStart_toStartOf="#+id/goalMinutes"
app:layout_constraintTop_toTopOf="#+id/goalMinutes" />
<TextView
android:id="#+id/secmarker"
android:layout_width="12dp"
android:layout_height="20dp"
android:layout_marginStart="148dp"
android:layout_marginLeft="148dp"
android:layout_marginTop="64dp"
android:fontFamily="#font/product_regular"
android:text="S"
android:textColor="#color/black"
android:textSize="17dp"
app:layout_constraintStart_toStartOf="#+id/goalMinutes"
app:layout_constraintTop_toTopOf="#+id/goalMinutes" />
<TextView
android:id="#+id/millimarker"
android:layout_width="27dp"
android:layout_height="19dp"
android:layout_marginStart="246dp"
android:layout_marginLeft="246dp"
android:layout_marginTop="64dp"
android:fontFamily="#font/product_regular"
android:text="MS"
android:textColor="#color/black"
android:textSize="17dp"
app:layout_constraintStart_toStartOf="#+id/goalMinutes"
app:layout_constraintTop_toTopOf="#+id/goalMinutes" />
<TextView
android:id="#+id/splashdebugoutput"
android:layout_width="wrap_content"
android:layout_height="37dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="#+id/course"
android:layout_width="118dp"
android:layout_height="36dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="233dp"
android:layout_marginRight="233dp"
android:background="#color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/resetbtn"></Spinner>
<Spinner
android:id="#+id/length"
android:layout_width="118dp"
android:layout_height="38dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="68dp"
android:layout_marginRight="68dp"
android:background="#color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/resetbtn"></Spinner>
<Button
android:id="#+id/startbtn"
android:layout_width="86dp"
android:layout_height="35dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#color/transparent"
app:layout_constraintEnd_toStartOf="#+id/pausebtn"
app:layout_constraintHorizontal_bias="0.741"
app:layout_constraintStart_toStartOf="#+id/splashdebugoutput"
app:layout_constraintTop_toBottomOf="#+id/goalMinutes" />
<EditText
android:id="#+id/tempoSeconds"
android:layout_width="30dp"
android:layout_height="47dp"
android:layout_marginStart="68dp"
android:layout_marginLeft="68dp"
android:layout_marginTop="448dp"
android:backgroundTint="#color/black"
android:maxLength="1"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="0"
android:inputType="numberPassword"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/texthint"
android:textSize="15dp"
android:verticalScrollbarPosition="right"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/tempoMilliTens"
android:layout_width="29dp"
android:layout_height="48dp"
android:layout_marginTop="448dp"
android:backgroundTint="#color/black"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="0"
android:inputType="numberPassword"
android:maxLength="1"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/texthint"
android:textSize="15dp"
app:layout_constraintStart_toEndOf="#+id/goal_colon"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/tempoMilliHundreds"
android:layout_width="30dp"
android:layout_height="48dp"
android:layout_marginTop="448dp"
android:backgroundTint="#color/black"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="0"
android:maxLength="1" android:inputType="numberPassword"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/texthint"
android:textSize="15dp"
app:layout_constraintStart_toEndOf="#+id/tempoMilliTens"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="#+id/splitAuto"
android:layout_width="174dp"
android:layout_height="26dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:button="#color/transparent"
android:background="#null"
android:scaleX="1.35"
android:scaleY="1.35"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/course" />
<CheckBox
android:id="#+id/splitManual"
android:layout_width="174dp"
android:layout_height="26dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:button="#color/transparent"
android:scaleX="1.35"
android:background="#null"
android:scaleY="1.35"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/splitAuto" />
<ImageView
android:id="#+id/checked1"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="153dp"
android:layout_marginRight="151dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/course" />
<ImageView
android:id="#+id/checked2"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginTop="87dp"
android:layout_marginEnd="153dp"
android:layout_marginRight="148dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/length" />
<ImageView
android:id="#+id/checked1u"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="153dp"
android:layout_marginRight="148dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/course" />
<ImageView
android:id="#+id/checked2u"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginTop="87dp"
android:layout_marginEnd="153dp"
android:layout_marginRight="152dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/length" />
<EditText
android:id="#+id/secInput"
android:layout_width="69dp"
android:layout_height="39dp"
android:layout_marginStart="132dp"
android:layout_marginLeft="132dp"
android:layout_marginTop="76dp"
android:backgroundTint="#color/black"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="Sec."
android:inputType="numberPassword"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/black"
android:textSize="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/splitAuto" />
<EditText
android:id="#+id/milliInput"
android:layout_width="69dp"
android:layout_height="39dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="76dp"
android:layout_marginEnd="132dp"
android:layout_marginRight="132dp"
android:backgroundTint="#color/black"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="Milli."
android:inputType="numberPassword"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/black"
android:textSize="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="#id/secInput"
app:layout_constraintTop_toBottomOf="#+id/splitAuto" />
<EditText
android:id="#+id/offset"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="76dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:backgroundTint="#color/black"
android:ems="10"
android:fontFamily="#font/product_regular"
android:hint="Time Offset Per Length"
android:inputType="numberPassword"
android:textAlignment="center"
android:textColor="#color/black"
android:textColorHint="#color/black"
android:textSize="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.507"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/splitAuto" />
<Button
android:id="#+id/add"
android:layout_width="101dp"
android:layout_height="35dp"
android:layout_marginStart="292dp"
android:layout_marginLeft="292dp"
android:layout_marginTop="124dp"
android:background="#color/transparent"
app:layout_constraintStart_toStartOf="#+id/splashdebugoutput"
app:layout_constraintTop_toBottomOf="#+id/splitManual" />
<Button
android:id="#+id/remove"
android:layout_width="101dp"
android:layout_height="35dp"
android:layout_marginTop="4dp"
android:background="#color/transparent"
app:layout_constraintEnd_toEndOf="#+id/add"
app:layout_constraintTop_toBottomOf="#+id/add" />
<ListView
android:id="#+id/splitList"
android:layout_width="113dp"
android:layout_height="95dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="140dp"
android:divider="#color/black"
android:dividerHeight="1dp"
android:scrollbarThumbVertical="#drawable/gray_scroll_style"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"></ListView>
<TextView
android:id="#+id/txtData"
android:layout_width="136dp"
android:layout_height="69dp"
android:layout_marginStart="132dp"
android:layout_marginLeft="132dp"
android:text="1"
android:visibility="invisible"
android:textColor="#color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/debugOutput2"
android:layout_width="96dp"
android:layout_height="69dp"
android:text="TextView"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Seems like you have a lot of hard coded density pixels there. Have you tried using dimen.xml?

Android Virtual Device detects wrong screen size?

When I fully edit GUI on android editor and run it. Android Virtual Device overlap it on the bottom corner.
I'm using android studio LATEST VERSION
Android Editor
Android Virtual Device(Nexus_5X_API_28)
<?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">
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,640:371"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.046"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="#drawable/header_bg" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintDimensionRatio="w,35:55"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:srcCompat="#drawable/book_cover" />
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:text="Buisness Advise for starting a small buisness"
android:textColor="#android:color/black"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView2"
app:layout_constraintTop_toBottomOf="#+id/imageView" />
<Button
android:id="#+id/buy"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/buy_button"
android:padding="10dp"
android:text="5$"
android:textColor="#android:color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="#+id/wishlist"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<Button
android:id="#+id/wishlist"
android:layout_width="172dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/buy_button"
android:padding="10dp"
android:text="WishList+"
android:textColor="#android:color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBaseline_toBaselineOf="#+id/buy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/buy" />
<ImageView
android:id="#+id/rating"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="44dp"
android:background="#drawable/rating"
app:layout_constraintEnd_toStartOf="#+id/comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/buy"
app:srcCompat="#drawable/ic_star"
tools:ignore="VectorDrawableCompat" />
<ImageView
android:id="#+id/comment"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/comment"
app:layout_constraintBottom_toBottomOf="#+id/rating"
app:layout_constraintEnd_toStartOf="#+id/style"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/rating"
app:layout_constraintTop_toTopOf="#+id/rating"
app:srcCompat="#drawable/ic_speaker"
tools:ignore="VectorDrawableCompat" />
<ImageView
android:id="#+id/style"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/style"
app:layout_constraintBottom_toBottomOf="#+id/comment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/comment"
app:layout_constraintTop_toTopOf="#+id/comment"
app:srcCompat="#drawable/ic_style"
tools:ignore="VectorDrawableCompat" />
<TextView
android:id="#+id/ratinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="4.5+"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/rating"
app:layout_constraintStart_toStartOf="#+id/rating"
app:layout_constraintTop_toBottomOf="#+id/rating" />
<TextView
android:id="#+id/commentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="Advices"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/comment"
app:layout_constraintStart_toStartOf="#+id/comment"
app:layout_constraintTop_toBottomOf="#+id/comment" />
<TextView
android:id="#+id/similarText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="Similar"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/style"
app:layout_constraintStart_toStartOf="#+id/style"
app:layout_constraintTop_toBottomOf="#+id/style" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="In this video, I am designing an Android App's Book Details/Buy Page UI(User Interface) with ConstraintLayout"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentText" />
</android.support.constraint.ConstraintLayout>
When I fully edit GUI on android editor and run it. Android Virtual Device overlap it on the bottom corner.
How can I fix this problem.
You can handle it by wrapping the xml layout with ScrollView, Please try this
<?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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,640:371"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.046"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="#drawable/ic_launcher_background" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintDimensionRatio="w,35:55"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:srcCompat="#drawable/ic_launcher_background" />
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:text="Buisness Advise for starting a small buisness"
android:textColor="#android:color/black"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView2"
app:layout_constraintTop_toBottomOf="#+id/imageView" />
<Button
android:id="#+id/buy"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/ic_launcher_background"
android:padding="10dp"
android:text="5$"
android:textColor="#android:color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="#+id/wishlist"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<Button
android:id="#+id/wishlist"
android:layout_width="172dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/ic_launcher_background"
android:padding="10dp"
android:text="WishList+"
android:textColor="#android:color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBaseline_toBaselineOf="#+id/buy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/buy" />
<ImageView
android:id="#+id/rating"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="44dp"
android:background="#drawable/ic_launcher_background"
app:layout_constraintEnd_toStartOf="#+id/comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/buy"
app:srcCompat="#drawable/ic_launcher_background"
tools:ignore="VectorDrawableCompat" />
<ImageView
android:id="#+id/comment"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/ic_launcher_background"
app:layout_constraintBottom_toBottomOf="#+id/rating"
app:layout_constraintEnd_toStartOf="#+id/style"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/rating"
app:layout_constraintTop_toTopOf="#+id/rating"
app:srcCompat="#drawable/ic_launcher_background"
tools:ignore="VectorDrawableCompat" />
<ImageView
android:id="#+id/style"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/ic_launcher_background"
app:layout_constraintBottom_toBottomOf="#+id/comment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/comment"
app:layout_constraintTop_toTopOf="#+id/comment"
app:srcCompat="#drawable/ic_launcher_background"
tools:ignore="VectorDrawableCompat" />
<TextView
android:id="#+id/ratinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="4.5+"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/rating"
app:layout_constraintStart_toStartOf="#+id/rating"
app:layout_constraintTop_toBottomOf="#+id/rating" />
<TextView
android:id="#+id/commentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="Advices"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/comment"
app:layout_constraintStart_toStartOf="#+id/comment"
app:layout_constraintTop_toBottomOf="#+id/comment" />
<TextView
android:id="#+id/similarText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="Similar"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/style"
app:layout_constraintStart_toStartOf="#+id/style"
app:layout_constraintTop_toBottomOf="#+id/style" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="In this video, I am designing an Android App's Book Details/Buy Page UI(User Interface) with ConstraintLayout"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentText" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Hide or Add Button in Constraint Layout based on some condition

I have this layout on Fragment. It has 3 Buttons. Below Button3 there is one TextView.When this layout is set I am checking some conditions. If that condition is satisfied I am showing the Button3. But if the condition is not satisfied I need to hide the button.
This is how the layout looks after hiding Button3
It appears to be a lot of blank space between the TextView and Button2 when the button is hidden but in my XML layout, it is present there. How to avoid this so that it doesn't appear blank space?
This is code for 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:id="#+id/myConstraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/allscreenbackground">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/tabIndicator"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Table: "
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBaseline_toBaselineOf="#+id/tableName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.03"
app:layout_constraintStart_toStartOf="#+id/toolbar2" />
<TextView
android:id="#+id/tableName"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text=""
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBaseline_toBaselineOf="#+id/full_name"
app:layout_constraintEnd_toEndOf="#+id/toolbar2"
app:layout_constraintHorizontal_bias="0.04"
app:layout_constraintStart_toEndOf="#+id/name" />
<TextView
android:id="#+id/full_name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="10dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ellipsize="marquee"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text=""
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/toolbar2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/tableName"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="0dp"
android:text="Pax -"
android:textColor="#color/textTitles"
android:textSize="18sp"
app:layout_constraintBaseline_toBaselineOf="#+id/people"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline4" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Occupied Since :"
android:textColor="#color/textTitles"
android:textSize="18sp"
app:layout_constraintBaseline_toBaselineOf="#+id/lapsedTime"
app:layout_constraintStart_toStartOf="#+id/guideline4" />
<TextView
android:id="#+id/people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text=""
android:textColor="#color/textTitles"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView9"
app:layout_constraintTop_toBottomOf="#+id/toolbar2"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/lapsedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text=""
android:textColor="#color/textTitles"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.06"
app:layout_constraintStart_toEndOf="#+id/textView10"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.18" />
<Button
android:id="#+id/shift"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/yes_button"
android:gravity="center"
android:text="Button 1"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold"
android:visibility="visible"
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.283" />
<Button
android:id="#+id/end"
android:layout_width="200dp"
android:layout_height="35dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/yes_button"
android:text="Button 2"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold"
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.387" />
<android.support.constraint.Guideline
android:id="#+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="40dp" />
<Button
android:id="#+id/freeThisTable"
android:layout_width="200dp"
android:layout_height="35dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/yes_button"
android:text="Button 3"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold"
android:visibility=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/isBday"
android:visibility="invisible"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.65"
app:srcCompat="#drawable/birthday" />
<ImageView
android:visibility="invisible"
android:id="#+id/isAniversary"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.78"
app:srcCompat="#drawable/ring_new" />
<TextView
android:visibility="visible"
android:id="#+id/isBdayText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="Hello"
android:textSize="18sp"
android:textColor="#color/textTitles"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline32"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.64" />
<TextView
android:visibility="invisible"
android:id="#+id/isAniversaryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textSize="18sp"
android:textColor="#color/textTitles"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline32"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.76" />
<android.support.constraint.Guideline
android:id="#+id/guideline32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="100dp" />
</android.support.constraint.ConstraintLayout>
If you want to hide the spaces of the object use it:
boolean myCondition = true;
if(myCondition) {
Button3.setVisibility(View.GONE);
}
else {
Button3.setVisibility(View.VISIBLE);
}
The problem was because of incorrect constraint. You have constrained most of your views TOP to parent and set bias to align it. Instead of that, do align under your consecutive views. It will work as your requirement.
For better understanding, I have edited your xml file. Replace and check it out.
<........./>
<android.support.constraint.Guideline
android:id="#+id/guideline4"
.............../>
<Button
android:id="#+id/freeThisTable"
android:layout_width="200dp"
android:layout_height="35dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="#drawable/yes_button"
android:text="Button 3"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/end" />
<ImageView
android:id="#+id/isBday"
android:layout_width="40dp"
android:layout_height="40dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#+id/isBdayText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline4"
app:layout_constraintTop_toTopOf="#+id/isBdayText"
app:srcCompat="#drawable/birthday" />
<ImageView
android:id="#+id/isAniversary"
android:layout_width="40dp"
android:layout_height="40dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#+id/isAniversaryText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline4"
app:layout_constraintTop_toTopOf="#+id/isAniversaryText"
app:srcCompat="#drawable/ring_new" />
<TextView
android:id="#+id/isBdayText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Hello"
android:textColor="#color/textTitles"
android:textSize="18sp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline32"
app:layout_constraintTop_toBottomOf="#+id/freeThisTable" />
<TextView
android:id="#+id/isAniversaryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="TextView"
android:textColor="#color/textTitles"
android:textSize="18sp"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/guideline32"
app:layout_constraintTop_toBottomOf="#+id/isBdayText" />
<android.support.constraint.Guideline
android:id="#+id/guideline32"
.............. />

need help figuring out how to compare user input and pulling data from a website using an api key

This is my first time programming in android studio and I need help in figuring out how to compare options selected by the user based on the radio buttons and query an api to pull data from a website. Below is the code of the layout.The results are supposed to be displayed on another page, thank you.
<?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"
android:background="#0663ba"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="81dp">
<Button
android:id="#+id/button"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="#000000"
android:text="#string/search"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText3" />
<EditText
android:id="#+id/editText"
android:layout_width="172dp"
android:layout_height="50dp"
android:layout_marginBottom="32dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:hint="#string/zip_code"
android:inputType="textPostalAddress"
app:layout_constraintBottom_toTopOf="#+id/textView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.04"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="MissingConstraints" />
<TextView
android:id="#+id/textView2"
android:layout_width="175dp"
android:layout_height="44dp"
android:layout_marginBottom="48dp"
android:layout_marginStart="8dp"
android:fontFamily="sans-serif"
android:text="#string/select_date_range"
android:textAppearance="#style/TextAppearance.AppCompat"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/textView3"
app:layout_constraintStart_toStartOf="parent" />
<RadioGroup
android:id="#+id/radioGroup6"
android:layout_width="144dp"
android:layout_height="0dp"
android:layout_marginBottom="14dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/radioGroup7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView2"
app:layout_constraintTop_toBottomOf="#+id/imageButton">
<RadioButton
android:id="#+id/radioButton8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:checked="true"
android:text="#string/_1_week"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<RadioButton
android:id="#+id/radioButton9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/_2_weeks"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<RadioButton
android:id="#+id/radioButton7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/_3_months"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_marginBottom="28dp"
android:layout_marginStart="16dp"
android:text="#string/select_crime_type"
android:textAppearance="#style/TextAppearance.AppCompat"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/textView4"
app:layout_constraintStart_toStartOf="parent" />
<RadioGroup
android:id="#+id/radioGroup7"
android:layout_width="144dp"
android:layout_height="0dp"
android:layout_marginBottom="11dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/textView4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/radioGroup6">
<RadioButton
android:id="#+id/radioButton13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rape"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<RadioButton
android:id="#+id/radioButton15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/assault"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<RadioButton
android:id="#+id/radioButton14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="#string/murder"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="33dp"
android:text="#string/search_for_criminal_or_victim"
android:textAlignment="viewStart"
android:textAppearance="#style/TextAppearance.AppCompat"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/editText3"
app:layout_constraintEnd_toEndOf="#+id/radioGroup7"
app:layout_constraintTop_toBottomOf="#+id/radioGroup7" />
<EditText
android:id="#+id/editText3"
android:layout_width="195dp"
android:layout_height="45dp"
android:layout_marginBottom="66dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:hint="#string/enter_full_name"
android:inputType="textPersonName"
android:textColor="#FFFFFF"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="147dp"
android:layout_marginBottom="76dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="#a91818"
android:scaleType="fitCenter"
android:src="#drawable/new_crime_img"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/radioGroup6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>

Categories

Resources