简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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