Android之View控件添加边框
2017-03-23 17:26
169 查看
1. 使用Shape画一张背景图,设置给background属性即可,代码如下
2. 某些需求可能只需要给View添加某一边或者多边边框, 可使用layer-list实现,代码如下
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ECECEC" /> <!--背景图颜色--> <stroke android:width="1dp" <!--边框宽度--> android:color="#CCCCCC" /> <!--边框颜色--> <padding <!--设置内边距--> android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> </shape>
2. 某些需求可能只需要给View添加某一边或者多边边框, 可使用layer-list实现,代码如下
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <solid android:color="#CCCCCC" /> </shape> </item> <item android:top="1dp" android:left="1dp" android:right="1dp"> <!----> <shape> <solid android:color="#ECECEC" /> </shape> </item> </layer-list>
相关文章推荐
- Android--为TextView添加边框
- Android 自定义View消除锯齿实现图片旋转,添加边框及文字说明
- Android 简单实现圆形ImageView添加双层圆形边框
- Android Lableview给控件添加标签
- Android应用:SurfaceView中添加控件
- Android--为TextView添加边框
- android 给LinearLayout中添加一定数量的控件,并让着一定数量的控件从右到左移动,每隔若干秒停顿一下,最后一个view链接第一个view,然后继续移动循环往复,形成一个死循环简单动画效果
- android开发之动态给HorizontalScrollView添加被包含控件
- Android使用自定义ImageView为图片添加边框
- android 自定义粘性View,可寄生于其他控件给予其添加半透明spinner的效果
- android 为TextView添加边框
- android 为TextView添加边框
- Android 为TextView 添加边框
- Android实战简易教程-第四枪(ScrollView和HorizontalScrollView动态添加控件并提供事件监听)
- android ImageView 添加边框
- 【Android游戏开发之六】在SurfaceView中添加系统控件,并且相互交互数据!
- Android给TextView和EditText等控件设置透明背景、圆角边框
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- android 为TextView添加边框
- 为android自定义View控件添加自定义的属性