Custom Rounded Linear Layout : Add Borders
I have developed a custom rounded LinearLayout and I want to add 1px border. Here my code : public class MyLinearLayout extends LinearLayout { private float radius; private Path p
Solution 1:
If you look closely at the rounded corners in your custom LinearLayout, you will probably see that the radius is not smooth. This is because there is a system limitation that does not support anti aliasing on Paths.
Here is a great tutorial from Erik Burke on how to properly create Views with rounded corners. Basically you will create an off-screen Bitmap, draw a RoundRectangle, and use an alpha compositing technique to merge the off-screen Bitmap with the custom LinearLayoutCanvas' Bitmap.
As far as a border, you can can draw it by setting Paint.Style.FILL_AND_STROKE to the Paint.
Post a Comment for "Custom Rounded Linear Layout : Add Borders"