http://blog.csdn.net/lovecluo/article/details/8710174
In our own app, in order to make the app look better, we need to turn our own view into rounded corners, after all, the mainstream is also a lot of things to make rounded corners, and the appearance of Apple looks similar, looks good.
It's also easy to make a view rounded, just build a custom drawable.
We set up a shape drawable below res/drawable, with the following code:
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android" > <CornersAndroid:topleftradius= "5DP"Android:toprightradius= "5DP"Android:bottomleftradius= "5DP"Android:bottomrightradius= "5DP"/> <StrokeAndroid:width= "1DP"Android:color= "#FF5500" /></Shape>
In this, corners refers to the rounded corners, the stroke refers to the border color, related information about shape can look at the official documents, or search online, there is a very detailed blog.
There was no problem, but I was in the back to do that only the left has rounded corners and only the right side has a fillet, there is a problem, that is, before android3.0, Android:bottomleftradius and Android: Bottomrightradius is the opposite, that is, I was just set to the left, but a diagonal display, because I did not learn, but in the internet for a long time did not find a solution, after knowing the Android loading layout file method, we know this solution , in this record, is in our res set up a directory called DRAWABLE-V12, this file directory is the location of the android3.0 after the version access, so only need to put the correct layout file inside this can be.
The code is as follows:
This is done below the android3.0 (all rounded corners on the left):
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android" > <CornersAndroid:topleftradius= "5DP"Android:bottomrightradius= "5DP"/> <StrokeAndroid:width= "1DP"Android:color= "#FF5500" /></Shape>
And in android3.0 above version, Google solves this problem for us, so we just need to follow the normal situation of writing, and put the file under the RES/DRAWABLE-V12, as follows:
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android" > <CornersAndroid:topleftradius= "5DP"Android:bottomleftradius= "5DP"/> <StrokeAndroid:width= "1DP"Android:color= "#FF5500" /></Shape>
On the right and above the solution is consistent, here will not repeat.
My source Address: http://download.csdn.net/detail/lovecluo/5173334
Android fillet view implementation and compatibility with different versions (android3.0 later)