逆水行舟用力撑,一篙松劲退千寻。这篇文章主要讲述ANDROID布局实现圆角边框相关的知识,希望能为你提供帮助。
首先,在res下面新建一个文件夹drawable,在drawable下面新建三个xml文件:shape_corner_down.xml、shape_corner_up.xml和shape_corner.xml,分别是下面两个角是圆角边框,上面两个角是圆角边框,四个角全部是圆角边框。
shape_corner_down.xml:
1 2 3 4 5 6 7 | <
?xml version= "1.0"
encoding= "utf-8" ?>
<
shape xmlns:android= "http://schemas.android.com/apk/res/android" >
<
solid android:color= "#0099CC"
/>
<
corners android:bottomRightRadius= "20dp"
android:bottomLeftRadius= "20dp" />
<
stroke android:width= "1dp"
android:color= "#000000" />
<
/shape>
|
1 2 3 4 5 6 7 | <
?xml version= "1.0"
encoding= "utf-8" ?>
<
shape xmlns:android= "http://schemas.android.com/apk/res/android" >
<
solid android:color= "#CCCC99"
/>
<
corners android:topLeftRadius= "20dp"
android:topRightRadius= "20dp"
/>
<
stroke android:width= "1dp"
android:color= "#000000"
/>
<
/shape>
|
1 2 3 4 5 6 7 8 9 | <
?xml version= "1.0"
encoding= "utf-8" ?>
<
shape xmlns:android= "http://schemas.android.com/apk/res/android" >
<
solid android:color= "#99CCFF"
/>
<
corners android:topLeftRadius= "20dp"
android:topRightRadius= "20dp"
android:bottomRightRadius= "20dp"
android:bottomLeftRadius= "20dp" />
<
stroke android:width= "1dp"
android:color= "#000000"
/>
<
/shape>
|
在activity_main.xml上面放置三个LinearLayout,分别设置android:background属性为shape_corner_up.xml、shape_corner_down.xml和shape_corner.xml,运行结果如下:
文章图片
推荐阅读
- Android零基础入门第78节(四大组件的纽带——Intent)
- 安卓平台ionic2微博和QQ登录
- Android——碎片事务调用失败
- Myeclipse开发安卓-安装ADT,SDK
- JavaFX高斯模糊效果
- JavaFX事件处理
- JavaFX FlowPane
- JavaFX FileChooser
- JavaFX填充过渡