首页 > 解决方案 > cardView android studio上的厚左边框

问题描述

这是我第一次创建移动应用程序。我使用 android studio 来开发它。我想问一下如何在cardView中创建一个厚的左边框?我很困惑。我在这个论坛上找到了,没有答案

有人可以帮助我吗?

我想创建这样的 卡片示例

但是我的代码就像 我刚刚创建的那样

<android.support.v7.widget.CardView
    android:id="@+id/cardView"
    style="@style/ListStyle"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.219">
</android.support.v7.widget.CardView>

如果需要,也可以选择样式

<style name="ListStyle" parent="Theme.AppCompat.NoActionBar">
    <item name="cardCornerRadius">2dp</item>
    <item name="cardElevation">2dp</item>
    <item name="contentPaddingBottom">24dp</item>
    <item name="contentPaddingTop">24dp</item>
    <item name="contentPaddingLeft">16dp</item>
    <item name="contentPaddingRight">16dp</item>
    <item name="cardBackgroundColor">@color/putih</item>
</style>

谢谢你帮助我:)

标签: android

解决方案


Use this code :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    style="@style/RippleStyleBlack"
    android:layout_width="match_parent"
    android:layout_marginTop="5dp"
    android:layout_height="wrap_content">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/seeall_lead_list"
        android:layout_width="match_parent"
        android:layout_height="90dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true">


        <android.support.v7.widget.CardView
            android:layout_margin="5dp"
            android:layout_width="match_parent"
            android:layout_height="84dp"
            android:layout_centerInParent="true"
            android:elevation="10dp"
          >

            <View
                android:layout_width="20dp"
                android:layout_height="match_parent"
                android:background="#D64D4D">

            </View>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <ImageView

                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:layout_marginLeft="25dp"
                    android:layout_marginTop="20dp"
                    android:src="@drawable/icon_image"

                    />


                <TextView

                    android:id="@+id/lead_NameNew"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="114dp"
                    android:text="Add List"
                    android:textAlignment="center"
                    android:textSize="30dp" />


            </RelativeLayout>
        </android.support.v7.widget.CardView>


    </RelativeLayout>



</RelativeLayout>

推荐阅读