Home > database >  XML Layout Material Card View border not showing
XML Layout Material Card View border not showing

Time:07-15

So I made a layout with Frame Layout and Scroll View. There are 3 material card view inside scroll view. But I dont know why the third card border is not showing and sometimes only the bottom border is missing. I think is because of the constraint and scroll view but I still cant solve it. Anyone knows?

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            >

            <com.google.android.material.card.MaterialCardView
                android:id="@ id/cv_item_info"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:backgroundTint="@color/white"
                app:cardCornerRadius="20dp"
                app:cardElevation="2dp"
                android:layout_marginEnd="10dp"
                android:layout_marginStart="10dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="15dp"
                    android:layout_marginBottom="15dp"
                    android:layout_marginStart="20dp"
                    android:layout_marginEnd="20dp"
                    android:orientation="vertical">
                    <TextView
                        android:id="@ id/tv_item_nama"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/nama_item"
                        android:textColorHint="@color/black"
                        android:fontFamily="@font/poppins_medium"
                        android:text=""
                        android:textStyle="bold"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:maxLines="1"
                        android:ellipsize="end"/>

                    <TextView
                        android:id="@ id/tv_item_category"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:hint="@string/category_item"
                        android:text=""
                        android:fontFamily="@font/poppins"
                        android:textSize="11sp"
                        android:maxLines="1"
                        android:ellipsize="end"/>

                    <TextView
                        android:id="@ id/tv_item_harga"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:hint="@string/harga_item"
                        android:textColorHint="@color/black"
                        android:text=""
                        android:fontFamily="@font/poppins"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:maxLines="1"
                        android:ellipsize="end" />

                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>

            <com.google.android.material.card.MaterialCardView
                android:id="@ id/cv_seller_profile"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:backgroundTint="@color/white"
                app:cardCornerRadius="20dp"
                app:cardElevation="2dp"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:layout_marginStart="10dp"
                app:layout_constraintTop_toBottomOf="@id/cv_item_info"
                app:layout_constraintStart_toStartOf="parent">

                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="15dp"
                    android:layout_marginBottom="15dp"
                    android:layout_marginStart="20dp"
                    android:layout_marginEnd="20dp">

                    <androidx.cardview.widget.CardView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        app:cardCornerRadius="20dp">

                        <ImageView
                            android:id="@ id/iv_seller_info"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:src="@mipmap/ic_launcher"
                            android:contentDescription="@string/seller_picture" />

                    </androidx.cardview.widget.CardView>

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        <TextView
                            android:id="@ id/tv_seller_nama"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:fontFamily="@font/poppins_medium"
                            android:textStyle="bold"
                            android:textColor="@color/black"
                            android:text=""
                            android:textSize="14sp"
                            android:hint="@string/seller_name"
                            android:textColorHint="@color/black"/>

                        <TextView
                            android:id="@ id/tv_seller_city"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:textSize="11sp"
                            android:text=""
                            android:fontFamily="@font/poppins"
                            android:hint="@string/seller_city"/>
                    </LinearLayout>
                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>

            <com.google.android.material.card.MaterialCardView
                android:id="@ id/cv_item_description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                app:cardCornerRadius="20dp"
                app:cardElevation="2dp"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:layout_marginStart="10dp"
                app:layout_constraintTop_toBottomOf="@id/cv_seller_profile"
                app:layout_constraintStart_toStartOf="parent">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="20dp">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/deskripsi"
                        android:fontFamily="@font/poppins_medium"
                        android:textColorHint="@color/black"
                        android:textStyle="bold"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:text=""/>

                    <TextView
                        android:id="@ id/tv_deskripsi"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:text="Test"
                        android:fontFamily="@font/poppins"
                        android:textSize="14sp"
                        android:textColor="@color/black" />
                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

Here is the example image of the layout I made. ImageLayout

CodePudding user response:

It happens because you do not have a bottom constraint on your last card. Add a constraint there, and your card will be displayed correctly

  • Related