Android中带有底线曲线的java自定义形状布局
我想做一个像图中一样的布局,底部弯曲
我尝试在stackoverflow中使用一些示例,但无法确切了解如何做到这一点
现在我正在尝试使用可绘制的xml并将其包含在布局中:
`<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:shape="rectangle">
<corners
安卓:bottomLeftRadius="0dp"
安卓:bottomRightRadius="5dp"
安卓:topLeftRadius="0dp"
安卓:topRightRadius="0dp" />
<padding
安卓:bottom="5dp"
安卓:left="20dp"
安卓:right="0dp"
安卓:top="0dp" />
<stroke
安卓:width="0.5dp"
安卓:color="@color/colorPrimary" />
<solid 安卓:color="@color/colorPrimary" />
</shape>`
# 1 楼答案
你可以这样做-
创建为自定义视图-
现在,在onDraw()方法中,您可以绘制为-
首先画一个高度为getHeight()的矩形/2
宽度=getWidth()
设置CustomDrawableView的高度和宽度以匹配父视图,还可以根据需要调整中心