简体   繁体   English

圆角而不禁用硬件加速

[英]Rounded corners without disabling hardwareacceleration

I'm trying to add rounded corners to a custom drawed view. 我正在尝试将圆角添加到自定义绘制视图中。 I recently found out the solution, but there has to be a better way i guess? 我最近找到了解决方案,但我想必须有更好的方法吗?

To add the corners, i'm using a path: 为了添加角落,我使用了一条路径:

Path mPath = new Path();
        mPath.addRoundRect(new RectF(0, 0, 100,100),20,20, Path.Direction.CCW);
        canvas.clipPath(mPath, Region.Op.INTERSECT);

But this only works, if I add android:hardwareAccelerated="false" to my manifest and I really don't want to add this line, as it slows down the app a lot! 但这只有在我将android:hardwareAccelerated="false"到清单中并且我真的不想添加此行的情况下才有效,因为这会大大降低应用程序的速度!

Can i get this to run without disabling the hardwareacceleration? 我可以在不禁用硬件加速的情况下使其运行吗?

My solution was to partially disable hardwareacceleration. 我的解决方案是部分禁用硬件加速。 I just disabled the hardwareacceleration for the view, where i needed the rounded corners, so the performance of the app doesn't got affected too much. 我只是禁用了需要圆角的视图的硬件加速,因此应用程序的性能不会受到太大影响。

Hope this helps others, who are forced with the same problem. 希望这对其他被迫面临同样问题的人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM