Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – How to set Textview height between two imageview

Posted on November 11, 2022 By

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?

READ  [FIXED] Android Studio 4.0 not showing build error details
Powered by Inline Related Posts

Comment posted by this out

Try

Android Tags:android, android-layout, imageview, textview, xml

Post navigation

Previous Post: [FIXED] React-native android build fails due to missing files in the gradle cache?
Next Post: Can I use Google storage instead of iCloud?

Related Posts

[FIXED] kotlin – Android worker – update and preserve state across retries Android
[FIXED] android – Fatal Exception: java.lang.RuntimeException:Using WebView from more than one process at once with the same data directory is not supported Android
[FIXED] encryption – How to encrypt/decrypt using the Android KeyStore with keeping compatibility? Android
[FIXED] android – Flutter app show grey screen in release mode but works fine in debug mode Instance of ‘DiagnosticsProperty‘ Android
[FIXED] android – Connecting Real time database to Authentication database on Firebase Android
[FIXED] Android Studio – How to have a transparent status bar? Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme