Hello I have a very weird problem that it drives me crazy. I have a DialogFragment and inside that a RecyclerView. I have a custom adapter for my RecyclerView and a custom XML layout for both the DialogFragment and the RecyclerView Adpater.
When I open the dialog the view is just fine. As it should be.
The problem appears when I click inside the EditText Field (the yellow box in picture) and the on screen keyboard pops up. Then for some reason the entire layout messes and it behaves as I defined it as WRAP_CONTENT.
I have no idea why is that happening. My code seems right and after looking up on other similar questions the code is right to my eyes.
This is the RecyclerView custom 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="wrap_content">
<TextView
android:id="#+id/packitemnoField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#drawable/ic_barcode_small"
android:drawablePadding="4dp"
android:paddingStart="4dp"
android:paddingTop="2dp"
android:paddingEnd="4dp"
android:paddingBottom="2dp"
android:textAlignment="viewStart"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="0062020512845" />
<TextView
android:id="#+id/qtyDescTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:text="#string/tweightLabel"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/packDescField" />
<TextView
android:id="#+id/RemainsDescTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
android:text="#string/weightLabel"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/qtyDescTV"
app:layout_constraintTop_toBottomOf="#+id/qtyDescTV" />
<TextView
android:id="#+id/thWeightField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:textColor="#color/darkGrey"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="#+id/qtyDescTV"
app:layout_constraintTop_toTopOf="#+id/qtyDescTV"
tools:text="9999 kg." />
<TextView
android:id="#+id/weightField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:textColor="#color/successGreen"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="#+id/qtyDescTV"
app:layout_constraintTop_toTopOf="#+id/RemainsDescTV"
tools:text="9999 kg." />
<TextView
android:id="#+id/packDescField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:textColor="#color/od_color1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/packitemnoField"
tools:text="ALBIO / ΠΡΟΦΙΛ ΠΕΛΑΤΗ" />
<ImageView
android:id="#+id/kgIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="4dp"
android:tint="#color/darkGrey"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/newWeightInput"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/newWeightInput"
app:srcCompat="#drawable/ic_weight" />
<EditText
android:id="#+id/newWeightInput"
android:layout_width="69dp"
android:layout_height="36dp"
android:layout_marginEnd="2dp"
android:background="#drawable/border_qty"
android:ems="10"
android:inputType="number"
android:maxLength="4"
android:padding="4dp"
android:textAlignment="center"
android:textColor="#color/colorSecondaryVariant"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/kgIcon"
app:layout_constraintTop_toTopOf="parent"
tools:text="9999" />
<TextView
android:id="#+id/packDateField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:text="26/03/2020"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/newWeightLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:text="#string/newWeight"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/newWeightInput"
app:layout_constraintEnd_toStartOf="#+id/newWeightInput"
app:layout_constraintTop_toTopOf="#+id/newWeightInput" />
</androidx.constraintlayout.widget.ConstraintLayout>
And this is the code in the onCreateViewHolder method in the adapter
#NonNull
#Override
public RecyclerView.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rvr_package, parent, false);
return new PackagesViewHolder(view);
}
Here is tha DialogFragment 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="wrap_content">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<Button
android:id="#+id/updateWeightBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:backgroundTint="#color/colorAccent"
android:text="#string/update"
app:layout_constraintBottom_toBottomOf="#+id/closeBtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline"
app:layout_constraintTop_toTopOf="#+id/closeBtn" />
<Button
android:id="#+id/closeBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:text="#string/close"
app:layout_constraintEnd_toStartOf="#+id/guideline"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/packagesRecyclerView" />
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/packagesRecyclerView"
android:layout_width="0dp"
android:layout_height="400dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
you can try add to your constraintLayout of DialogFragment this line :
android:fitsSystemWindows="true"
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/packagesRecyclerView"
android:layout_width="match_parent"
android:layout_height="400dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Related
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>
I have a custom XML file for the options menu which I want to display underneath an ImageButton when it is clicked. I want to be able to get the id (or a name, index...) of the item from the menu when the item is selected.
Here's the XML file of recycler_view_item.xml which is the layout with the ImageButton that's supposed to show the menu on click:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:layout_marginBottom="55dp"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_anchorGravity="center_horizontal">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="0dp"
app:cardBackgroundColor="#182A3E"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="382dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="0dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="43dp"
android:background="#drawable/recycler_item_background"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_item_title"
android:layout_width="200dp"
android:layout_height="43dp"
android:layout_gravity="center_horizontal"
android:layout_marginStart="90dp"
android:layout_marginEnd="0dp"
android:gravity="center|center_horizontal"
android:text="Placeholder"
android:textColor="#F9F9F9"
android:textSize="20sp" />
<ImageButton
android:id="#+id/optionsMenuButton"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:paddingLeft="20dp"
android:paddingTop="3dp"
android:paddingRight="20dp"
app:srcCompat="#drawable/ic_options_menu_icon" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/subRecyclerView"
android:layout_width="356dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Here's the XML file of options_menu_view.xml, which is the menu I want to display on click of the optionsMenuButton from the code above:
<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:id="#+id/optionsMenu"
android:layout_width="190dp"
android:layout_height="118dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/ic_options_menu_background"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/addSubitem"
android:layout_width="match_parent"
android:layout_height="39dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#drawable/ic_add_subitem_icon" />
<TextView
android:id="#+id/addItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
android:layout_marginTop="11dp"
android:fontFamily="#font/segoe_regular"
android:text="Add Item"
android:textColor="#EBEBEB"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="172dp"
android:layout_height="1dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/options_menu_divider" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/editGroup"
android:layout_width="match_parent"
android:layout_height="39dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#drawable/ic_edit_group_icon" />
<TextView
android:id="#+id/editGroupText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
android:layout_marginTop="11dp"
android:fontFamily="#font/segoe_regular"
android:text="Edit Group"
android:textColor="#EBEBEB"
android:textSize="17sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="172dp"
android:layout_height="1dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/options_menu_divider" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/deleteGroup"
android:layout_width="match_parent"
android:layout_height="39dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_delete_group_icon" />
<TextView
android:id="#+id/deleteGroupText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
android:layout_marginTop="9dp"
android:fontFamily="#font/segoe_regular"
android:text="Delete Group"
android:textColor="#C93434"
android:textSize="17sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
What I would like it to look like when displayed:
Option Menu Example
I've been trying to find the solution for quite some time, but I'm quite new and to be honest, I don't even know what exactly I'm supposed to be searching for. Your help is greatly appreciated and sorry if this was posted in the past.
Thank you in advance.
I have buttons what I made with "LinearLayout" but when I want to made them clickable and so that it goes to another activity. I understand, that I need to change from "LinearLayout" to "ImageButton" because I want to make a beautiful app [what I want it looks like][1], but when I launch it, it stops working. What can I do to repair that? Thank you in advance for your help and sorry for my bad english. :(
<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:background="#color/colorBackground"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_background"
android:padding="20dp"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textHello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="#string/hello"
android:textColor="#color/colorWhite"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TextContrastCheck" />
<TextView
android:id="#+id/textUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="#string/vassili"
android:textColor="#color/colorWhite"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/textHello"
tools:ignore="TextContrastCheck" />
<ImageView
android:id="#+id/imageMenu"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_menu"
app:layout_constraintBottom_toBottomOf="#id/textHello"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#id/textHello"
app:tint="#color/colorWhite"
tools:ignore="ImageContrastCheck" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/layoutHeader"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="-96dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/layoutGoal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:background="#drawable/white_background_icons"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp"
app:layout_constraintDimensionRatio="H, 1:1"
app:layout_constraintEnd_toStartOf="#id/layoutTraining"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="#string/app_name"
android:padding="8dp"
android:src="#drawable/notepad" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/goals"
android:textColor="#color/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/layoutTraining"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:background="#drawable/white_background_icons"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp"
app:layout_constraintDimensionRatio="H, 1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/layoutGoal"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="#string/app_name"
android:padding="8dp"
android:src="#drawable/dumbbell" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/Trainings"
android:textColor="#color/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/layoutWater"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:background="#drawable/white_background_icons"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp"
app:layout_constraintDimensionRatio="H, 1:1"
app:layout_constraintEnd_toStartOf="#id/layoutTraining"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/layoutGoal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="#string/app_name"
android:padding="8dp"
android:src="#drawable/bottle" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/Water"
android:textColor="#color/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/layoutStepCounter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:background="#drawable/white_background_icons"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp"
app:layout_constraintDimensionRatio="H, 1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/layoutGoal"
app:layout_constraintTop_toBottomOf="#id/layoutTraining"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="#string/app_name"
android:padding="8dp"
android:src="#drawable/walk" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/step_counter"
android:textColor="#color/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
[1]: https://i.stack.imgur.com/WdW6v.png
May you need to change constraintlayout to LinearLayout and if you want click be on image add id to imageview
For this type of layout you need to make your LinearLayout clickable
For example:
LinearLayout linearLayoutGoals;
then in you onCreate do findViewById and set its clickListener
linearLayoutGoals = findViewById(R.id.layoutGoal);
linearLayoutGoals.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//DO YOUR CODE
}
});
I have a scrollView in my xml. There's ConstraintLayout inside of it. In the ConstraintLayout is my RecyclerView. It's invisible. When I change ScrollView to ConstraintLayout everything gets back to normal. Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true"
tools:context=".ui.fragments.ChannelAudioFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/allChannelAudiosProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/noAudiosTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
android:gravity="center|left"
android:text="No audios"
android:layout_marginTop="5dp"
android:textSize="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/channelAudiosRefreshSwipe"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingConstraints">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvAllChannelAudios"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I don't get any errors in console. Why is this happening?
UPDATE
Additional info: I'm using it in ViewPager. Here it is
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ui.fragments.ChannelFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/channelBlock"
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_margin="30dp"
android:background="#drawable/main_background"
android:padding="20dp"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/ivChannelImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/ic_person_flat"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Qewbite"
android:textColor="#color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="26sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/ivChannelImage" />
<LinearLayout
android:id="#+id/subscriptionBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/channelName"
android:gravity="center_vertical">
<Button
android:id="#+id/subscribeButton"
android:layout_width="wrap_content"
android:textAllCaps="false"
android:layout_height="40dp"
android:textSize="12dp"
android:gravity="center"
android:background="#drawable/subscribed_background"
android:padding="0dp"
app:backgroundTint="#color/colorDark"
android:textColor="#color/whiteColor"
android:layout_marginLeft="5dp"
android:text="Unfollow" />
<ImageButton
android:id="#+id/notificationButton"
android:layout_width="40dp"
android:textAllCaps="false"
android:layout_height="40dp"
android:textSize="12dp"
android:tint="#color/whiteColor"
android:src="#drawable/ic_notification"
app:backgroundTint="#color/colorDark"
android:background="#drawable/subscribe_notification_background"
android:padding="0dp"
android:textColor="#color/whiteColor" />
</LinearLayout>
<View
android:id="#+id/headerHr"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorNavbarGray"
app:layout_constraintTop_toBottomOf="#id/subscriptionBlock"
android:layout_marginTop="10dp"
/>
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelSubscribers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10M"
android:textColor="#color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="#id/channelSubscribersTitle"
app:layout_constraintEnd_toEndOf="#id/channelSubscribersTitle"
app:layout_constraintTop_toBottomOf="#id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelSubscribersTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Followers"
android:textColor="#color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/channelSubscribers" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelListened"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="120M"
android:textColor="#color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="#id/channelListenedTitle"
app:layout_constraintEnd_toEndOf="#id/channelListenedTitle"
app:layout_constraintTop_toBottomOf="#id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelListenedTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auditions"
android:textColor="#color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/channelListened" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021"
android:textColor="#color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/channelYearTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Year"
android:textColor="#color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="#id/channelYear"
app:layout_constraintEnd_toEndOf="#id/channelYear"
app:layout_constraintTop_toBottomOf="#id/channelSubscribers" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabSelectedTextColor="#color/colorPrimary"
app:layout_constraintTop_toBottomOf="#id/channelBlock"
app:layout_constraintStart_toStartOf="#id/channelBlock"
app:tabRippleColor="#color/colorGray"
android:layout_marginTop="8dp" />
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/channelViewPager"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_constraintTop_toBottomOf="#id/tab"
app:layout_constraintStart_toStartOf="#id/tab" />
</androidx.constraintlayout.widget.ConstraintLayout>
Most probably that is because you put more than 1 view inside ScrollView , ScrollView expects 1 view from you. If you want to put more than one consider using a viewGroup view and put your views inside it. For Instance , you can use a vertical LinearLayout to wrap the Views you used. Also , consider using NestedScrollView instead.
Try this one
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh"
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.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<ProgressBar
android:id="#+id/allChannelAudiosProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/noAudiosTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
android:gravity="center|left"
android:text="No audios"
android:layout_marginTop="5dp"
android:textSize="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvAllChannelAudios"
tools:listitem="#layout/event_near_items"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="10"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
swipe_refresh.setOnRefreshListener {
swipe_refresh.isRefreshing = false
// refresh the list here
}
Why not try a nested scroll view.
I built an application (for practice Android), and i use start, end in order to support both LTR and RTL languages. I also set android:supportsRtl="true" in manifest file.
When device is set to LTR language all text looks great, and alignment great to the left. But, when changing device language to RTL language, all text seems bad and isn't alignment to the right (maybe some of the TextView are alignment and some aren't). In addition it seems that the Spinner view is totally Wrong. I have attached two screen shot (for both languages). I'm asking for your help, because i don't understand what i'm doing wrong.
Also attached 3 code snipping (one for all the layout, the second for the item inside the RecyclerView and the third the item for the Spinner:
<?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:background="#color/backgroundColor">
<Spinner
android:id="#+id/spinner"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginStart="3dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="3dp"
android:background="#null"
android:dropDownWidth="120dp"
android:dropDownVerticalOffset="96dp"
android:gravity="center"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.example.currencyconvertor.MultiButton
android:id="#+id/multiButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginTop="15dp"
app:activeButtonIndex="0"
app:backgroundSelector="#drawable/multi_button_background_selector"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/spinner"
app:numOfButtons="2"
app:reversedOrder="false"
android:visibility="gone"
app:textColorSelector="#drawable/multi_button_text_color" />
<TextView
android:id="#+id/textView1"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginTop="22dp"
android:textColor="#color/titleTextColor"
android:textSize="13sp"
app:layout_constraintEnd_toStartOf="#id/textView2"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/multiButton"
tools:text="TextView1" />
<TextView
android:id="#+id/textView2"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="Symbol"
android:textColor="#color/titleTextColor"
android:textSize="13sp"
app:layout_constraintEnd_toStartOf="#id/textView3"
app:layout_constraintStart_toEndOf="#id/textView1"
app:layout_constraintTop_toTopOf="#id/textView1"
tools:text="TextView2" />
<TextView
android:id="#+id/textView3"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:textColor="#color/titleTextColor"
android:textSize="13sp"
app:layout_constraintEnd_toStartOf="#id/textView4"
app:layout_constraintStart_toEndOf="#id/textView2"
app:layout_constraintTop_toTopOf="#id/textView1"
app:layout_goneMarginEnd="3dp"
tools:text="TextView3" />
<TextView
android:id="#+id/textView4"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:textColor="#color/titleTextColor"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/textView3"
app:layout_constraintTop_toTopOf="#id/textView1"
android:visibility="gone"
tools:text="TextView4" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="3dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="3dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView1"
tools:listitem="#layout/relative_currency_rate_row" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="200dp"
android:maxWidth="200dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView1" />
</androidx.constraintlayout.widget.ConstraintLayout>
Code for RecyclerView item:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="1dp"
android:background="#color/rowColor"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/container"
android:layout_width="80dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="#id/targetCountryTextView"
app:layout_constraintHorizontal_chainStyle="spread_inside"
tools:ignore="MissingConstraints">
<ImageView android:id="#+id/countryFlagImageView"
android:layout_width="32dp"
android:layout_height="32dp"
app:layout_constraintStart_toStartOf="#id/container"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="#drawable/ic_launcher_background"
android:paddingEnd="4dp" />
<TextView
android:id="#+id/currencyTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="#id/countryFlagImageView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="2dp"
android:layout_marginTop="13dp"
android:layout_marginBottom="12dp"
android:textSize="13sp"
android:text="USA"
android:textColor="#color/currencyRowTextColor"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="#+id/targetCountryTextView"
android:layout_width="80dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="#id/container"
app:layout_constraintEnd_toStartOf="#id/rateTextView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="13dp"
android:layout_marginBottom="12dp"
android:textSize="13sp"
android:text="Dollar"
android:textColor="#color/currencyRowTextColor" />
<TextView
android:id="#+id/rateTextView"
android:layout_width="80dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="#id/targetCountryTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="13dp"
android:layout_marginBottom="12dp"
android:textSize="13sp"
android:text="0.417"
android:textColor="#color/currencyRowTextColor" />
</androidx.constraintlayout.widget.ConstraintLayout>
Code for Spinner item:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/rowColor">
<ImageView
android:id="#+id/flagImageView"
android:layout_width="48dp"
android:layout_height="48dp"
app:layout_constraintEnd_toStartOf="#+id/countryTextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:padding="4dp"
app:srcCompat="#drawable/default_glag"
android:textColor="#color/currencyRowTextColor"/>
<TextView
android:id="#+id/countryTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/flagImageView"
android:layout_marginStart="30dp"
android:gravity="center"
android:textSize="17sp"
android:textColor="#color/currencyRowTextColor"/>
<TextView
android:id="#+id/currencyTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/countryTextView"
android:layout_marginStart="5dp"
android:gravity="center"
android:text="countryCurrencyTextView"
android:textSize="17sp"
android:textColor="#color/currencyRowTextColor"/>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="4dp"
android:src="#mipmap/ic_arrow_drop_down"/>
</androidx.constraintlayout.widget.ConstraintLayout>[![enter image description here][1]][1]
disable supports RTL on your manifest file:
<application
...
android:supportsRtl="false">
I hope to be useful ;)