如何在CardView中剪切垂直线? [英] How I can clipping vertical line in a CardView?
本文介绍了如何在CardView中剪切垂直线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在CardView半径中剪切垂直线视图
I want clipping vertical line view in radius CardView
喜欢这张照片:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_margin="20dp"
app:cardCornerRadius="40dp">
<!-- radiused vertical line here -->
</android.support.v7.widget.CardView>
</LinearLayout>
推荐答案
您可以尝试为剪切视图设置弯曲的背景资源.
You can try setting curved-shaped background resource for the clipping views.
这是一个示例形状文件,您需要根据需要修改半径值.
Here is a sample shape file, you need to modify the radius values according to your need.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#a40404" />
<corners
android:topRightRadius="40dp"
android:bottomRightRadius="40dp"/>
</shape>
以及CardView主布局:
And the main CardView layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_margin="20dp"
app:cardCornerRadius="40dp"
app:cardPreventCornerOverlap="false">
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/curved_bg" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginTop="3dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="3dp"
android:background="@drawable/curved_bg" />
</android.support.v7.widget.CardView>
</LinearLayout>
这篇关于如何在CardView中剪切垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文