Solution 1 :
The dotted_line_order
ImageView constrained to order_date_time
TextView Using app:layout_constraintTop_toBottomOf="@+id/order_date_time"
.
While the overlapped order_items
TextView constrained to dotted_line_order
ImageView with app:layout_constraintBottom_toTopOf="@+id/dotted_line_order"
.
Both constraints will make the order_items
overlaps with the dotted_line_order
.
You need to replace the 1st constraint to be constrained to the order_items
instead of the order_date_time
, so it should be app:layout_constraintTop_toBottomOf="@+id/order_items"
<ImageView
android_id="@+id/dotted_line_order"
android_layout_width="match_parent"
android_layout_height="5dp"
android_layout_marginTop="80dp"
android_layerType="software"
app_layout_constraintTop_toBottomOf="@+id/order_items"
android_src="@drawable/dotted" />
Also, check if 80dp margin as it seems some how big.
Problem :
I have a TextView
to display order items and quantity. But it overlaps with the divider lines above and below. How to fix this?
<?xml version="1.0" encoding="utf-8"?><!--https://www.youtube.com/watch?v=18VcnYN5_LM !-->
<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"
android_animateLayoutChanges="true"
android_animationCache="true"
android_gravity="center|start"
android_orientation="vertical"
android_padding="0dp">
<com.google.android.material.card.MaterialCardView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_layout_marginStart="5dp"
android_layout_marginEnd="5dp"
android_layout_marginBottom="15dp"
android_layout_marginTop="10dp"
android_elevation="50dp"
app_strokeColor="@color/grey600"
app_strokeWidth="1dp"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android_layout_width="match_parent"
android_layout_height="match_parent">
<com.skydoves.androidribbon.RibbonView
android_id="@+id/order_status_ribbon"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_fontFamily="@font/poppins_bold"
android_letterSpacing=".10"
android_text="@string/order_status"
android_textColor="#FFFFFF"
android_textSize="12sp"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toTopOf="parent"
app_layout_constraintVertical_bias="0.0"
app_ribbon_background_color="@color/primaryYellow"
app_ribbon_padding_top="4dp"
app_ribbon_ribbonRadius="4dp"
app_textAllCaps="true" />
<TextView
android_id="@+id/order_id"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginStart="8dp"
android_layout_marginTop="8dp"
android_fontFamily="@font/poppins_semibold"
android_text="@string/sample_order_id"
android_textColor="#000000"
android_textSize="14sp"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@+id/order_status_ribbon" />
<TextView
android_id="@+id/order_date_time"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginStart="8dp"
android_layout_marginTop="4dp"
android_fontFamily="@font/poppins"
android_text="@string/date_amp_time"
android_textColor="@color/grey600"
android_textSize="11sp"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@+id/order_id" />
<ImageView
android_id="@+id/dotted_line_order_after_date_time"
android_layout_width="match_parent"
android_layout_height="5dp"
android_layout_marginTop="8dp"
android_layerType="software"
android_src="@drawable/dotted"
app_layout_constraintTop_toBottomOf="@+id/order_date_time"
tools_layout_editor_absoluteX="0dp" />
<TextView
android_id="@+id/order_items"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_margin="16dp"
android_fontFamily="@font/poppins"
android_text="@string/order_items_and_quantity"
android_textColor="@color/black"
app_layout_constraintBottom_toTopOf="@+id/dotted_line_order"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@+id/dotted_line_order_after_date_time"
app_layout_constraintVertical_bias="0.418" />
<ImageView
android_id="@+id/dotted_line_order"
android_layout_width="match_parent"
android_layout_height="5dp"
android_layout_marginTop="80dp"
android_layerType="software"
android_src="@drawable/dotted"
app_layout_constraintTop_toBottomOf="@+id/order_date_time"
tools_layout_editor_absoluteX="0dp" />
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_layout_marginTop="4dp"
android_fontFamily="@font/poppins_medium"
android_gravity="center"
android_paddingBottom="10dp"
android_text="@string/view_details"
android_textColor="@color/black"
app_layout_constraintTop_toBottomOf="@+id/dotted_line_order"
tools_layout_editor_absoluteX="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Sample image is found in https://imgur.com/a/EPsUeI3
As you can see in the image the order items and quantity TextView
is overlapping with ImageView
. The text for TextView
comes from a StringBuffer
sb.append(n.getInt("quantiy"));
sb.append(" X ");
sb.append(n.getString("name"));
sb.append("n");
holder.orderItems.setText(sb);
Comments
Comment posted by Developer Sunshine
Could you please add expected image?
Comment posted by this out
Try