How to let user add new plain texts in Android Studio? - java

I'm working on this project with my classmates, and we decided to do a recipe app. I'm working on the create recipe screen. Instead of adding multiline text for the instructions, I added plain text(1 for each instruction) just so that the appearance of all the recipes will be consistent. At first, it will start of with one instruction and then I want the user to be able to add more from then on.
here's the xml :
<?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"
android:contentDescription="#string/app_name" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTxtRecipeName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/recipe_name"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/addThumbnail"
android:importantForAutofill="no" />
<TextView
android:id="#+id/txtCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="#font/arya_bold"
android:text="#string/cuisine"
android:textColor="#FF6700"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtRecipeName" />
<Spinner
android:id="#+id/spnCountries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/txtCountry"
app:layout_constraintStart_toEndOf="#+id/txtCountry"
app:layout_constraintTop_toTopOf="#+id/txtCountry"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/countries"/>
<TextView
android:id="#+id/txtEquipment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:fontFamily="#font/arya_bold"
android:text="#string/equipment"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/txtDuration"
app:layout_constraintTop_toBottomOf="#+id/txtDuration" />
<EditText
android:id="#+id/editTxtEquipment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/_200c_fan_oven"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtEquipment"
android:importantForAutofill="no" />
<ImageButton
android:id="#+id/btnImgAddEquip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtEquipment"
app:srcCompat="#android:drawable/ic_menu_add"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
android:id="#+id/txtIngredients"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/ingredients"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/editTxtEquipment"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddEquip" />
<EditText
android:id="#+id/editTxtIngredient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/_500g_chicken_diced"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtIngredients"
android:importantForAutofill="no" />
<ImageButton
android:id="#+id/btnImgAddIngr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtIngredient"
app:srcCompat="#android:drawable/ic_menu_add"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
android:id="#+id/txtMethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/method"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/editTxtIngredient"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddIngr" />
<ImageButton
android:id="#+id/btnImgAddMethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
android:contentDescription="#string/add_image_to_method"
app:layout_constraintEnd_toEndOf="#+id/editTxtMethod"
app:layout_constraintHorizontal_bias="0.39"
app:layout_constraintStart_toStartOf="#+id/editTxtMethod"
app:layout_constraintTop_toBottomOf="#+id/editTxtMethod"
app:srcCompat="#android:drawable/ic_menu_gallery" />
<ImageButton
android:id="#+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:backgroundTint="#004E98"
android:contentDescription="#string/add_another_step"
app:layout_constraintBottom_toBottomOf="#+id/btnImgAddMethod"
app:layout_constraintStart_toEndOf="#+id/btnImgAddMethod"
app:layout_constraintTop_toTopOf="#+id/btnImgAddMethod"
app:srcCompat="#android:drawable/ic_menu_add" />
<ImageView
android:id="#+id/viewThumbnail"
android:layout_width="149dp"
android:layout_height="149dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#android:drawable/ic_menu_gallery" />
<Button
android:id="#+id/addThumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
android:text="#string/thumbnail"
app:layout_constraintEnd_toEndOf="#+id/viewThumbnail"
app:layout_constraintStart_toStartOf="#+id/viewThumbnail"
app:layout_constraintTop_toBottomOf="#+id/viewThumbnail" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="95dp"
android:backgroundTint="#004E98"
android:text="#string/video"
app:layout_constraintBottom_toBottomOf="#+id/addThumbnail"
app:layout_constraintStart_toEndOf="#+id/addThumbnail"
app:layout_constraintTop_toTopOf="#+id/addThumbnail"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="#+id/viewVideo"
android:layout_width="164dp"
android:layout_height="149dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.743"
app:layout_constraintStart_toEndOf="#+id/viewThumbnail"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#android:drawable/ic_menu_slideshow" />
<TextView
android:id="#+id/txtCultureDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/personal_story"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddMethod" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="64dp"
android:backgroundTint="#004E98"
android:text="#string/button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editPersonalStory" />
<EditText
android:id="#+id/editPersonalStory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:gravity="start|top"
android:hint="#string/tell_us_about_your_culture_country"
android:inputType="textMultiLine"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtCultureDescription"
android:importantForAutofill="no" />
<EditText
android:id="#+id/editTxtMethod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:gravity="start|top"
android:hint="#string/pan_fry_chicken_fr_10_mins"
android:inputType="textMultiLine"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtMethod"
android:importantForAutofill="no" />
<TextView
android:id="#+id/txtDuration"
android:layout_width="90dp"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:fontFamily="#font/arya_bold"
android:text="#string/approx_cooking_time"
android:textColor="#FF6700"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="#+id/txtCountry"
app:layout_constraintTop_toBottomOf="#+id/txtCountry" />
<Spinner
android:id="#+id/spnHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/txtDuration"
app:layout_constraintStart_toEndOf="#+id/txtDuration"
app:layout_constraintTop_toTopOf="#+id/txtDuration"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/hours"/>
<TextView
android:id="#+id/txtHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="#string/hrs"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/spnHours"
app:layout_constraintStart_toEndOf="#+id/spnHours"
app:layout_constraintTop_toTopOf="#+id/spnHours" />
<Spinner
android:id="#+id/spnMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/spnHours"
app:layout_constraintStart_toEndOf="#+id/txtHours"
app:layout_constraintTop_toTopOf="#+id/spnHours"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/minutes"/>
<TextView
android:id="#+id/txtMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="#string/mins"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/spnMinutes"
app:layout_constraintStart_toEndOf="#+id/spnMinutes"
app:layout_constraintTop_toTopOf="#+id/spnMinutes" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="395dp" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I originally thought I would be able to write to the activity_main.xml using the MainActivity.java, but apparently the xml files are read-only. I know the answer sounds obvious after typing that, but is there a way to dynamically change the layout?

What you want is to create a dynamic list with a RecyclerView. There are some sample apps at the bottom to help you get started.
If you have any questions after reading feel free to edit your post or create another one.

RecylerView is the correct way to do it . But since you are a beginner to android i presume use ArrayAdapter for any list like elements.
"change the layout dynamically" is a bit broad but use
// view is any element in your code
view.visibility = View.Visible
view.visibility = View.GONE
XML based layout works on events ..what i mean by that is something happens when you interact . So for example if you want an image to disappear on the click of a button you would do something like
view.setOnCLickListener{
imageview.visibility = View.GONE
}

Related

Android UI broken when run

I am facing very strange problem, though I am beginner level on Android. after designed my layout file, when i run this android project by using physical device then i actually not find expected UI.
Here is the Layout UI and it's XML code:-
Design:-
XML 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=".activities.DetailedActivity">
<ImageView
android:id="#+id/detailed_img"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_launcher_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.Toolbar
android:id="#+id/detailed_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Product Detailed" />
<androidx.cardview.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:elevation="10dp"
android:translationY="-50dp"
app:cardCornerRadius="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/detailed_img">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/detailed_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="Product Name"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="#+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_toStartOf="#id/my_rating"
android:fontFamily="#font/amethysta"
android:text="4.0"
android:textColor="#color/black"
android:textSize="16sp" />
<RatingBar
android:id="#+id/my_rating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.1" />
</RelativeLayout>
<TextView
android:id="#+id/detailed_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="#font/amethysta"
android:text="am following the standard example of how to add a RatingBar. To con The problem is that the number of stars doesn't seem to do anything a" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:fontFamily="#font/amethysta"
android:text="Price"
android:textColor="#color/black"
android:textSize="21sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="$"
android:textColor="#color/purple_700"
android:textStyle="bold" />
<TextView
android:id="#+id/detailed_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="20"
android:textColor="#color/purple_700"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="#+id/add_item"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="7dp"
android:src="#drawable/plusicon" />
<TextView
android:id="#+id/quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="30sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/remove_item"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="7dp"
android:src="#drawable/iconminus" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<Button
android:id="#+id/add_to_cart"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="#color/pink"
android:drawableLeft="#drawable/mycart"
android:drawableTint="#color/white"
android:padding="14dp"
android:text="Add To Cart"
android:textAllCaps="false"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/buy_now"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardview"
app:layout_constraintVertical_bias="1"
app:layout_constraintWidth_percent=".8" />
<Button
android:id="#+id/buy_now"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_baseline_shopping_cart_24"
android:drawableTint="#color/white"
android:padding="14dp"
android:text="Buy Now"
android:textAllCaps="false"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent=".8" />
</androidx.constraintlayout.widget.ConstraintLayout>
And this is my physical devices unexpected output:-
I don't understand why this output act like that and which is totally unexpected. how I resolve this issue.
Since your CardView is not constrained by the buttons at the bottom the CardView will take space beyond those buttons. In the screenshot provided from a real device, it is clear that there is not much space to completely accommodate the contents in the CardView hence it will be pushed beyond the button. You need to add constraints to CardView to align it with the bottom button also you need to add a ScrollView if there is more content that the screen can't fully accommodate. Using this layout may improve the UI
<?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=".activities.DetailedActivity">
<ImageView
android:id="#+id/detailed_img"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_launcher_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.Toolbar
android:id="#+id/detailed_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Product Detailed" />
<androidx.cardview.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:elevation="10dp"
android:translationY="-50dp"
app:cardCornerRadius="10dp"
app:layout_constraintBottom_toTopOf="#+id/add_to_cart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/detailed_img">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/detailed_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="Product Name"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="#+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_toStartOf="#id/my_rating"
android:fontFamily="#font/amethysta"
android:text="4.0"
android:textColor="#color/black"
android:textSize="16sp" />
<RatingBar
android:id="#+id/my_rating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.1" />
</RelativeLayout>
<TextView
android:id="#+id/detailed_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="#font/amethysta"
android:text="am following the standard example of how to add a RatingBar. To con The problem is that the number of stars doesn't seem to do anything a" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:fontFamily="#font/amethysta"
android:text="Price"
android:textColor="#color/black"
android:textSize="21sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="$"
android:textColor="#color/purple_700"
android:textStyle="bold" />
<TextView
android:id="#+id/detailed_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/amethysta"
android:text="20"
android:textColor="#color/purple_700"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="#+id/add_item"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="7dp"
android:src="#drawable/plusicon" />
<TextView
android:id="#+id/quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="30sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/remove_item"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="7dp"
android:src="#drawable/iconminus" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
<Button
android:id="#+id/add_to_cart"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="#color/pink"
android:drawableLeft="#drawable/mycart"
android:drawableTint="#color/white"
android:padding="14dp"
android:text="Add To Cart"
android:textAllCaps="false"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/buy_now"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent=".8" />
<Button
android:id="#+id/buy_now"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_baseline_shopping_cart_24"
android:drawableTint="#color/white"
android:padding="14dp"
android:text="Buy Now"
android:textAllCaps="false"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent=".8" />
</androidx.constraintlayout.widget.ConstraintLayout>

How to adjust my app's text and widgets straight

I'm new to working with android layout, I'm building a form app but all my text widgets, dropdowns, and edit text are moving to the left can anyone tell what's wrong?
PS: Code will be appreciated
<?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="wrap_content"
android:padding="40dp"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="159dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="126dp"
android:text="ERDI"
android:textColor="#000000"
android:textSize="40sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView5" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="58dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="208dp"
android:text="Spectre Shape"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner3" />
<TextView
android:id="#+id/textView4"
android:layout_width="136dp"
android:layout_height="21dp"
android:layout_marginStart="56dp"
android:layout_marginTop="108dp"
android:layout_marginEnd="179dp"
android:gravity="right"
android:text="Collateral Damage"
android:textAlignment="gravity"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<TextView
android:id="#+id/textView5"
android:layout_width="118dp"
android:layout_height="25dp"
android:layout_marginStart="56dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="196dp"
android:text="Ground Shaking"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner2" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="128dp"
android:layout_marginEnd="238dp"
android:text="Hazard"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editTextTextPersonName4"
android:layout_width="252dp"
android:layout_height="46dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="63dp"
android:ems="10"
android:hint="Enter the Height..."
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView18" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="229dp"
android:text="Zone Factor"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner5" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView3" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView8" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="148dp"
android:text="FSI (Floor Space Index)"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner4" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="72dp"
android:layout_marginEnd="215dp"
android:text="Exposure"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editTextTextPersonName4" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="224dp"
android:text="Importance I"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
<EditText
android:id="#+id/editTextTextPersonName2"
android:layout_width="255dp"
android:layout_height="47dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="60dp"
android:ems="10"
android:hint="Enter the FSI..."
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView10" />
<Spinner
android:id="#+id/spinner7"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
<Spinner
android:id="#+id/spinner6"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView12" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="89dp"
android:text="Economic Loss Inducing Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner6" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="139dp"
android:text="Life Threatening Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView11" />
<Button
android:id="#+id/postdataBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="147dp"
android:layout_marginTop="108dp"
android:layout_marginEnd="133dp"
android:text="SUBMIT"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner7" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="127dp"
android:layout_marginTop="80dp"
android:layout_marginEnd="108dp"
android:text="Vulnerability"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editTextTextPersonName2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I'm using constraint layout inside Scroll View layout, I tried various text alignment, widget alignment but the layout still remains to align left.
I Have Used Linear Layout And Updated Your Code to look like a form
If it Helps Accept My Answer !!
<?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.appcompat.widget.LinearLayoutCompat
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="40dp"
android:gravity="start"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ERDI"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
/>
<Spinner
android:id="#+id/spinner3"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Spectre Shape"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView4"
android:layout_width="136dp"
android:layout_height="21dp"
android:layout_marginTop="20dp"
android:gravity="right"
android:text="Collateral Damage"
android:textAlignment="gravity"
android:textSize="16sp"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinner5"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView5"
android:layout_width="118dp"
android:layout_height="25dp"
android:layout_marginTop="24dp"
android:text="Ground Shaking"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Hazard"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextTextPersonName4"
android:layout_width="252dp"
android:layout_height="46dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Enter the Height..."
android:inputType="textPersonName"/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Zone Factor"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinner2"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"/>
<Spinner
android:id="#+id/spinner4"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"/>
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="FSI (Floor Space Index)"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Exposure"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Importance I"
android:textSize="16sp"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextTextPersonName2"
android:layout_width="255dp"
android:layout_height="47dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Enter the FSI..."
android:inputType="textPersonName"/>
<Spinner
android:id="#+id/spinner7"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="12dp"/>
<Spinner
android:id="#+id/spinner6"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Economic Loss Inducing Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Life Threatening Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<Button
android:id="#+id/postdataBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="108dp"
android:text="SUBMIT"
android:layout_gravity="center" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:text="Vulnerability"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
What I would suggest you to do is to fit everything into a Linear Layout, like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
your code here
</ScrollView>
</LinearLayout>
Also, as someone said in your comments, you should, inside of the ScrollView, use LinearLayout with vertical alignment, and then use proper paddings and margins in order to make the UI look good. You can use gravity and layout-gravity to align every element you want.

How do i get rid of this gap between the toolbar and the recycler view?

I am a beginner in native android programming. Would like to seek some guidance and help to get rid of this gap in between the toolbar and my recycler view. Read through some write-ups on people who faced the same issue but majority of these had included a "Coordinator Layout" or "layout_gravity". However, I did not have those in my code. Tried many other ways but couldn't make it work.
Here is a picture that is based on the code! The embedded picture shows a better contrast for the gap. Sorry my account doesn't allow any embedding of photos yet.
Here is my code for the parent recycler view.
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvProfile"
android:layout_width="403dp"
android:layout_height="match_parent"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp" />
Here is the code for my individual item layout.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/profileImage"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="29dp"
android:background="#drawable/profile"></ImageView>
<TextView
android:id="#+id/profileUserName"
android:layout_width="wrap_content"
android:layout_height="29dp"
android:layout_alignParentTop="true"
android:layout_marginStart="4dp"
android:layout_marginTop="1dp"
android:layout_toEndOf="#+id/profileImage"
android:text="User Name"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:id="#+id/changeProfilePicture"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_below="#+id/profileUserName"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="#+id/profileImage"
android:background="#color/zxing_transparent"
android:text="Change Profile Picture"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"></Button>
<Button
android:id="#+id/changePasswordBtn"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_below="#+id/changeProfilePicture"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_toEndOf="#+id/profileImage"
android:background="#color/zxing_transparent"
android:text="Change Password"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"></Button>
<TextView
android:id="#+id/accountbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/profileImage"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="1dp"
android:layout_marginTop="-1dp"
android:layout_marginEnd="0dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Account"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
<TextView
android:id="#+id/pointsTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/accountbar"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Points"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<TextView
android:id="#+id/pointsDisplay"
android:layout_width="157dp"
android:layout_height="wrap_content"
android:layout_below="#+id/accountbar"
android:layout_marginStart="131dp"
android:layout_marginTop="6dp"
android:layout_toEndOf="#+id/pointsTxt"
android:text="42 Points"
android:textColor="#color/textColorLight"
android:textSize="20sp"></TextView>
<TextView
android:id="#+id/orderHistoryTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pointsTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="0dp"
android:text="Order History"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:id="#+id/orderHistBtn"
android:layout_width="33dp"
android:layout_height="28dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="178dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:layout_toEndOf="#+id/orderHistoryTxt"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtExpenseTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="1dp"
android:text="Expense Tracker"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="141dp"
android:layout_marginTop="44dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtExpenseTracker"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtCurrencyConvertor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="37dp"
android:text="Currency Convertor"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="30dp"
android:layout_height="24dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="176dp"
android:layout_marginTop="210dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtPrivacyPolicy"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/othersbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:layout_below="#+id/profileImage"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="1dp"
android:layout_marginTop="206dp"
android:layout_marginEnd="0dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Others"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
<TextView
android:id="#+id/txtShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="140dp"
android:text="Share Krysjay with friends"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="37dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtShare"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtPrivacyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="172dp"
android:text="Privacy Policy"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="110dp"
android:layout_marginTop="-97dp"
android:layout_marginEnd="15dp"
android:layout_toEndOf="#+id/txtCurrencyConvertor"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtTermsCons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="205dp"
android:text="Terms & Conditions"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="105dp"
android:layout_marginTop="66dp"
android:layout_marginEnd="17dp"
android:layout_toEndOf="#+id/txtTermsCons"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<Button
android:id="#+id/signOutBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txtPrivacyPolicy"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:layout_marginTop="27dp"
android:layout_marginBottom="132dp"
android:background="#color/zxing_transparent"
android:outlineAmbientShadowColor="#color/colorPrimaryDark"
android:paddingStart="30dp"
android:text="Sign Out"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Have you tried to remove this line of code from your imageView?
android:layout_marginTop="67dp"
<RelativeLayout
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">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/profileImage"
android:layout_width="111dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#drawable/profile"></ImageView>
<TextView
android:id="#+id/accountbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Account"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/profileImage"/>
<TextView
android:id="#+id/profileUserName"
android:layout_width="wrap_content"
android:layout_height="29dp"
android:text="User Name"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#id/accountbar"
app:layout_constraintTop_toBottomOf="#id/profileImage"></TextView>
<Button
android:id="#+id/changeProfilePicture"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginStart="4dp"
android:background="#color/zxing_transparent"
android:text="Change Profile Picture"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"
app:layout_constraintEnd_toStartOf="#id/pointsDisplay"
app:layout_constraintHorizontal_bias="0.516"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/accountbar"></Button>
<Button
android:id="#+id/changePasswordBtn"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:background="#color/zxing_transparent"
android:text="Change Password"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"
app:layout_constraintEnd_toStartOf="#id/pointsDisplay"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/changeProfilePicture"></Button>
<TextView
android:id="#+id/pointsTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="8dp"
android:text="Points"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/accountbar"></TextView>
<TextView
android:id="#+id/pointsDisplay"
android:layout_width="157dp"
android:layout_height="wrap_content"
android:layout_marginStart="131dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="15dp"
android:text="42 Points"
android:textColor="#color/textColorLight"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/accountbar"></TextView>
<TextView
android:id="#+id/orderHistoryTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Order History"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/pointsTxt"></TextView>
<Button
android:id="#+id/orderHistBtn"
android:layout_width="33dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/orderHistoryTxt"
app:layout_constraintTop_toBottomOf="#id/changePasswordBtn"></Button>
<TextView
android:id="#+id/txtExpenseTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Expense Tracker"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/orderHistoryTxt"></TextView>
<Button
android:id="#+id/btnExpenseTracker"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtExpenseTracker"
app:layout_constraintTop_toBottomOf="#id/orderHistBtn"></Button>
<TextView
android:id="#+id/txtCurrencyConvertor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Currency Convertor"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtExpenseTracker"></TextView>
<Button
android:id="#+id/button"
android:layout_width="30dp"
android:layout_height="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtPrivacyPolicy"
app:layout_constraintTop_toBottomOf="#id/btnShareWithFriends"></Button>
<TextView
android:id="#+id/othersbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:layout_marginTop="4dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Others"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtCurrencyConvertor" />
<TextView
android:id="#+id/txtShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Share Krysjay with friends"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/othersbar"></TextView>
<Button
android:id="#+id/btnShareWithFriends"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtShare"
app:layout_constraintTop_toBottomOf="#id/othersbar"></Button>
<TextView
android:id="#+id/txtPrivacyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Privacy Policy"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtShare"></TextView>
<Button
android:id="#+id/btnCurrencyCovertor"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtCurrencyConvertor"
app:layout_constraintTop_toBottomOf="#id/btnExpenseTracker"></Button>
<TextView
android:id="#+id/txtTermsCons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Terms & Conditions"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtPrivacyPolicy"></TextView>
<Button
android:id="#+id/btnTermsCond"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#+id/txtTermsCons"
app:layout_constraintTop_toBottomOf="#+id/button"></Button>
<Button
android:id="#+id/signOutBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/txtPrivacyPolicy"
android:layout_alignParentStart="true"
android:layout_marginTop="4dp"
android:background="#color/zxing_transparent"
android:outlineAmbientShadowColor="#color/colorPrimaryDark"
android:paddingStart="30dp"
android:text="Sign Out"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtTermsCons" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

how to scroll my screen

<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="com.code.zero.drivermechanicsapp.AccidentAlertFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
because as i type it will block the screen. i cant even see what im typing.
and i'm really new in this android development. i don't know what to do.
can you please help me with this>?
because as i type it will block the screen. i cant even see what im typing.
and i'm really new in this android development. i don't know what to do.
can you please help me with this>?
put your views in scrollView like below:
<FrameLayout 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"
>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
</LinearLayout>
</ScrollView>
</FrameLayout>
To scroll your screen you simply need to do put a ScrollView inside your layout, like that:
<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="com.code.zero.drivermechanicsapp.AccidentAlertFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
</ScrollView>
If it says ScrollView can only have one child. Put the children in a single Layout like LinearLayout.

android app having different orientation for its items when changing the screen

My items on large screen like 10.1 works fine and every item in its position but if I change the screen to 4 or 3, some of my items disappear and some appear in large font related to the device screen, so I want it to appear all items on its correct positions so if the app run on small screen the font small and every thing in its normal position, also with large screen. So what I have to do to my xml to get my goal?
this is my xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:fadingEdge="none"
android:background="#BFAF80"
android:scrollbars="none"
android:scrollbarSize="0dp"
android:paddingRight="0dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#BFAF80"
android:id="#+id/CreatClear"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Bwt"
android:textStyle="bold"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp"
android:hint="#string/body_weight"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Age"
android:textStyle="bold"
android:gravity="center"
android:hint="#string/age_years"
android:layout_below="#+id/Hit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Screat"
android:gravity="center"
android:textStyle="bold"
android:hint="#string/serum_creatinine"
android:layout_below="#+id/Age"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/Cfemale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginTop="28dp"
android:layout_below="#+id/Screat"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/Cmale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_below="#+id/Cfemale"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="#+id/calcH"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="#+id/calc"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/ic_launcher"
android:clickable="true"
android:gravity="center" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="#+id/clearH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignBottom="#+id/sex"
android:layout_toLeftOf="#+id/sexa1"
android:layout_toStartOf="#+id/sexa1" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="#+id/clear"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignTop="#+id/clearH"
android:layout_alignLeft="#+id/clearH"
android:layout_alignStart="#+id/clearH" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="#+id/menuH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/sex"
android:layout_toEndOf="#+id/sex" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="#+id/menu"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/sex"
android:layout_toEndOf="#+id/sex" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Hit"
android:textStyle="bold"
android:gravity="center"
android:hint="#string/height_cm"
android:layout_below="#+id/Bwt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f"/>
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/Serum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_large_material"
android:lines="#integer/abc_max_action_buttons"
android:autoText="false"
android:background="#color/ripple_material_dark"
android:layout_above="#+id/blank"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/newSerum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_large_material"
android:layout_above="#+id/calcH"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:lines="#integer/abc_max_action_buttons"
android:background="#color/ripple_material_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nIBW"
android:id="#+id/nIBW"
android:layout_below="#+id/Cmale"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="34dp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nABW"
android:id="#+id/nABW"
android:layout_alignBottom="#+id/nIBW"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sex"
android:layout_alignTop="#+id/Cfemale"
android:layout_toRightOf="#+id/Screat"
android:layout_toEndOf="#+id/Screat"
android:gravity="center"
android:text="Gender"
android:visibility="invisible"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_alignParentTop="true"
android:layout_marginTop="604dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sexa1"
android:gravity="center"
android:text="Gender1"
android:visibility="invisible"
android:layout_alignTop="#+id/Cfemale"
android:layout_alignRight="#+id/nIBW"
android:layout_alignEnd="#+id/nIBW" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sexa2"
android:gravity="center"
android:text="Gender2"
android:visibility="invisible"
android:layout_alignTop="#+id/sexa1"
android:layout_alignRight="#+id/sexa1"
android:layout_alignEnd="#+id/sexa1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/BSA"
android:gravity="center"
android:text="Body Surface Area"
android:visibility="invisible"
android:layout_below="#+id/Cmale"
android:layout_toLeftOf="#+id/nABW"
android:layout_toStartOf="#+id/nABW" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/blank"
android:layout_above="#+id/newSerum"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Creat Clear (ml/min)"
android:id="#+id/HSerum"
android:gravity="center"
android:textColor="#ffffffff"
android:textStyle="bold"
android:background="#color/background_material_dark"
android:textSize="#dimen/abc_text_size_large_material"
android:layout_alignTop="#+id/BSA"
android:layout_toRightOf="#+id/Screat"
android:layout_toEndOf="#+id/Screat"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
Create a some resource directories called values-swXXXdp in res folder where XXX means smallest screen witdh.
In each directory create a file called dimens.xml and define the dimension for each swXXXdp:
<dimen name="custom_width">40dp</dimen>
Then, to retrieve that value in xml do the following: for example the width of a view:
android:layout_width="#dimen/custom_width"

Categories