سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top