Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当app:cornerRadius大的时候,然后高度不太高,背景会变成一个圆形 #24

Open
lishy24 opened this issue Dec 18, 2018 · 2 comments

Comments

@lishy24
Copy link

lishy24 commented Dec 18, 2018

No description provided.

@lishy24
Copy link
Author

lishy24 commented Dec 18, 2018

当高度为70dp, cornerRadius为30dp,就会导致背景是一个圆

@TheMandalorianHub
Copy link

如果四周的圆角都差不多一致的话可以考虑下这个方法:
在源代码的shapeutils 里添加

fun roundedRect2(
left: Float, top: Float, right: Float, bottom: Float,
tl: Float, tr: Float, br: Float, bl: Float): Path {
var tl = tl
var tr = tr
var br = br
var bl = bl
val path = Path()
if (tl < 0) tl = 0f
if (tr < 0) tr = 0f
if (br < 0) br = 0f
if (bl < 0) bl = 0f
var roundRect = RectF(left, top, right, bottom)
path.addRoundRect(roundRect,floatArrayOf(tl,tl,tr,tr,br,br,bl,bl), Path.Direction.CW)
return path
}

在主源代码的shadowview 的onDraw方法里的ShapeUtils.roundedRect 更改为ShapeUtils.roundedRect2

原先的rect只要是cornerradius达到了高度的一半就会变成圆,而且原先的绘制方式达不到左右俩边是完整半圆的情况

这个方式只适用于四周圆角值一致的情况,其他的一些情况的话可能会导致一些不一样的问题发生,可以考虑引入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants