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

设置background导致的显示问题 #1

Open
liuly0218 opened this issue Oct 9, 2017 · 5 comments
Open

设置background导致的显示问题 #1

liuly0218 opened this issue Oct 9, 2017 · 5 comments

Comments

@liuly0218
Copy link

给该布局添加background颜色,该布局还会直接显示直角矩形背景颜色,不过可以通过在该布局内部定义其他布局解决,这个能否直接定义background达到圆角矩形?

@GcsSloop
Copy link
Owner

GcsSloop commented Oct 9, 2017

由于 View 的 drawBackground 方法是私有的,无法重载,所以这个暂时没有想到比较好的解决方案,等我想到了就更新。

@p0sitive
Copy link

可以在draw方法中对canvas进行clip操作,这样在设置background就可以生效了

@GcsSloop
Copy link
Owner

发布之前就试过了,无效。

@ParfoisMeng
Copy link

@GcsSloop
未经测试,简单提一下想法:
1,给RCRelativeLayout内置一个match_parent的View,xml设置自定义属性为该view背景,可以达到需求效果。
2,copy一份RelativeLayout、ViewGroup、View的源码,修改将方法开放。
只是想法,没有实践,如有不妥请包涵。

@huihy
Copy link

huihy commented Jan 2, 2018

clip操作是对canvas的,所以在draw里面进行clip操作是ok的
代码如下:
@OverRide
public void draw(Canvas canvas) {
canvas.clipPath(mClipPath);
super.draw(canvas);
}

@GcsSloop GcsSloop added the fixed label Jan 5, 2018
GcsSloop pushed a commit that referenced this issue Apr 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants