android - 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>
谢谢你帮助我:)
解决方案
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>
推荐阅读
- java - Java 无法运行 H2o 苏打水,java.lang.NumberFormatException:不是版本:9
- android - 为什么在显示键盘时,前面会出现一个空白区域?
- python-3.x - 如何从文本文件中的python字符串中删除空['']
- python - 如何每次迭代更新单个嵌套字典
- javascript - 将图像(base64)附加到输入类型=“文件”
- android - 如何在 android studio 中设置当前 Xcode 版本?
- python - 带有 pygame 状态的平滑运动
- c++ - C++虚拟指针及其机制
- amazon-web-services - 带有 S3 存储桶的 AWS Cloudfront 配置为从裸域重定向到 www
- java - 如何避免 WorkManager Periodic Fetch Task 与我的主要 App Fetch 方法并行运行?