I am working with the design of a CardView where I have some TextView to show some data, but I need to put a “+” icon to add it to a sale, but I cannot place it on the right side as shown in the image and center it both horizontally as upright.
I hope you can support me.
Thank you
My trailer code (commented icon)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/card">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="No Venta"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="#000000" />
<TextView
android:id="@+id/txtVID"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="#000000" />
<TextView
android:id="@+id/txtCodigo"
android:text="KD546SD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:paddingLeft="60dp"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:layout_gravity="right"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtDescrip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:text="Producto"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/colorPrimary"
android:layout_marginLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:paddingLeft="15dp"
android:text="$"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small.Inverse"
android:textStyle="bold" />
<TextView
android:id="@+id/txtVPrecio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:paddingRight="15dp"
android:text="150.15"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small.Inverse"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!--<ImageView-->
<!--android:id="@+id/imgView"-->
<!--android:layout_width="40dp"-->
<!--android:layout_height="40dp"-->
<!--android:padding="4dp"-->
<!--android:src="@drawable/ic_edit_regular"-->
<!--android:layout_weight="1"/>-->
</androidx.cardview.widget.CardView>
</LinearLayout>
Result I need with the icon
You could add an identifier to your
Layout
inner second so you can align the elementImageView
, and add attributes to it:Design:
Result:
I hope it helps you.