-
Notifications
You must be signed in to change notification settings - Fork 399
CoorChice edited this page Feb 19, 2019
·
1 revision
SuperTextView 支持通过属性设置实现控件的圆角效果。从此,开发者不必为圆角背景而创建大量的 <shape>
文件。
在 xml 中:
<SuperTextView
...
app:stv_corner="25dp"
...
/>
在 Java 中:
stv.setCorner(25);
如果你需要实现圆形效果,只需要将corner
值设置为控件最大边长度的一半,即:corner = layout_width / 2
。比如:
<SuperTextView
...
android:layout_width="80dp"
android:layout_height="80dp"
app:stv_corner="40dp"
app:stv_solid="#008673"
...
/>
默认情况下,对 SuperTextView 设置 corner
会对控件的4个角都有效。当然,也可以单独指定那一个角才是真正需要圆角化的。
在 xml 中:
<SuperTextView
...
//设置左上角圆角
app:stv_left_top_corner="true"
//设置右上角圆角
app:stv_right_top_corner="true"
//设置左下角圆角
app:stv_left_bottom_corner="true"
//设置右下角圆角
app:stv_right_bottom_corner="true"
...
/>
在 Java 中:
//设置左上角圆角
stv.setLeftTopCornerEnable( boolean);
// 设置左下角圆角
stv.setLeftBottomCornerEnable( boolean);
//设置右上角圆角
stv.setRightTopCornerEnable(boolean);
//设置右下角圆角
stv.setRightBottomCornerEnable(boolean);