为控件设置某几个边的边框
2017-07-28 15:33
92 查看
边框等一般都在drawable中设置,然后作为background。但是边框的设置只支持全方位的设置,如果想设置某个边的边框的话,有一种思路,就是使用两层绘制。比如我想在白色的控件左边加一个0.5dp黑色的边框。那么就先用黑色定义一个shape,然后再用白色定义一个,设置左边留出0.5dp。这样就达到了效果:
代码中的例子在左边和上边设置了边框,并且左上角还有一个圆角。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- This is the main color --> <item> <shape> <corners android:topLeftRadius="2dp"/> <!-- 边框颜色 --> <solid android:color="#8493a8"/> </shape> </item> <item android:top="0.5dp" android:left="0.5dp"> <shape> <corners android:topLeftRadius="2dp"/> <!-- View填充颜色 --> <solid android:color="#eceff4" /> </shape> </item> </layer-list>
代码中的例子在左边和上边设置了边框,并且左上角还有一个圆角。
相关文章推荐
- iOS 设置控件的边框、圆角
- 设置UI控件的Layer属性(边框可见,边框颜色,边框宽度,边框圆角)
- android控件的边框设置
- Flex中如何通过borderThickness样式设置NumericStepper控件边框厚度的例子
- 设置NumericStepper控件获得焦点时的边框粗细.
- 设置控件边框的样式
- Flex中通过borderColor样式设置NumericStepper控件边框颜色的例子
- iPhone 控件边框设置
- android ImageView 圆角控件 设置上下左右某几个为圆角
- android控件的边框设置
- IOS设置UIView、UIButton等控件的边框设置为圆角
- iOS 设置控件圆角及边框
- /**切控件圆角 设置边框*/
- IOS开发中设置控件内容对齐方式时容易混淆的几个属性
- 控件设置背景色 以及 QPushButton 隐藏边框
- Qt Designer控件背景颜色及边框设置
- 设置NumericStepper控件获得焦点时的边框透明度.
- 设置ComboBox控件的边框颜色.
- (iPad/iPhone)给各种控件设置边框或圆角
- iOS 中使用xib创建的控件边框和颜色等设置