-
Notifications
You must be signed in to change notification settings - Fork 7
/
activity_shape_display.xml
179 lines (166 loc) · 8.23 KB
/
activity_shape_display.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.kk.android.comvvmhelper.binding.ShapeMode" />
<import type="com.kk.android.comvvmhelper.binding.GradientType" />
<import type="com.kk.android.comvvmhelper.binding.GradientOrientation" />
</data>
<!--
shape_mode="[ShapeMode.RECTANGLE(0) | ShapeMode.OVAL(1) | ShapeMode.LINE(2)]"
solid_color="color value need match regex [`#xxxxxxxx` | `#xxxxxx`]"
stroke_color="color for stroke line, value rule is same as solid_color"
stroke_width="the width for stroke line(float type)"
stroke_dash="worked with stroke_dash_gap to set stroke is a dashed_like(float value)"
stroke_dash_gap="worked with stroke_dash to set stroke is a dashed_like(float value)"
radius="corner radius(float value)"
radius_lt="radius for left-top corner(float value)"
radius_rt="radius for right-top corner(float value)"
radius_rb="radius for right-bottom corner(float value)"
radius_lb="radius for left-bottom corner(float value)"
start_color="gradient start color, value rule is same as solid_color"
center_color="gradient center color, value rule is same as solid_color"
end_color="gradient end color, value rule is same as solid_color"
gradient_orientation="[GradientOrientation.TOP_BOTTOM(0) | GradientOrientation.TR_BL(1)
| GradientOrientation.RIGHT_LEFT(2) | GradientOrientation.BR_TL(3) | GradientOrientation.BOTTOM_TOP(4)
| GradientOrientation.BL_TR(5) | GradientOrientation.LEFT_RIGHT(6) | GradientOrientation.TL_BR(7)]"
gradient_type="[GradientType.LINEAR(0) | GradientType.RADIAL(1) | GradientType.SWEEP(2)]"
radial_center_x="the center-x value for radial gradient(float type from 0f to 1f)"
radial_center_y="the center-y value for radial gradient(float type from 0f to 1f)"
radial_radius="radius for radial gradient"
-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.ShapeDisplayActivity"
tools:ignore="HardcodedText">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Background By DataBinding"
android:textColor="#666666"
android:textSize="20sp" />
<!-- radius: the corner radius-->
<!-- solid_color: the background color -->
<!-- stroke_color: the color for stroke line -->
<!-- if set a stroke line, the stroke_width is necessary -->
<!-- if the stroke line is dash mode, dash and dash_gap is necessary -->
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Set a round shape background with stroke"
android:textColor="@android:color/white"
android:textSize="16sp"
radius="@{12f}"
solid_color="@{`#cccccc`}"
stroke_color="@{`#000ccc`}"
stroke_dash="@{2f}"
stroke_dash_gap="@{2f}"
stroke_width="@{1f}" />
<!-- if wanna set a different corner radius shape, replace radius by radius_lb/lt/rb/rt -->
<!-- radius_lt means the left-top corner radius -->
<!-- radius_lb means the left-bottom corner radius -->
<!-- radius_rt means the right-top corner radius -->
<!-- radius_rb means the right-bottom corner radius -->
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Set diff radius corner shape"
android:textColor="@android:color/white"
android:textSize="16sp"
radius_lb="@{4f}"
radius_lt="@{12f}"
radius_rb="@{12f}"
radius_rt="@{4f}"
solid_color="@{`#AAABBB`}"
stroke_color="@{`#000000`}"
stroke_width="@{1f}" />
<!--
means for gradient_orientation:
TOP_BOTTOM gradient is from top to bottom
TR_BL gradient is from top-right to bottom-left
RIGHT_LEFT gradient is from right to left
BR_TL gradient is from bottom-right to top-left
BOTTOM_TOP gradient is from bottom to top
BL_TR gradient is from bottom-left to top-right
LEFT_RIGHT gradient is from left to right
TL_BR gradient is from top-left to bottom-right
-->
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Set rectangle gradient shape with round corner"
android:textColor="@android:color/white"
android:textSize="16sp"
center_color="@{`#aaa888`}"
end_color="@{`#fffccc`}"
gradient_orientation="@{GradientOrientation.TL_BR}"
gradient_type="@{GradientType.LINEAR}"
radius="@{15f}"
shape_mode="@{ShapeMode.RECTANGLE}"
start_color="@{`#666aaa`}" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Sweep Type"
android:textColor="@android:color/white"
android:textSize="16sp"
center_color="@{`#888888`}"
end_color="@{`#bbbbbb`}"
gradient_orientation="@{GradientOrientation.TL_BR}"
gradient_type="@{GradientType.SWEEP}"
radius="@{15f}"
shape_mode="@{ShapeMode.OVAL}"
start_color="@{`#333333`}" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Radial Type"
android:textColor="@android:color/white"
center_color="@{`#aaa888`}"
end_color="@{`#fffccc`}"
gradient_orientation="@{GradientOrientation.BL_TR}"
gradient_type="@{GradientType.RADIAL}"
radial_center_x="@{0.4f}"
radial_center_y="@{0.6f}"
radial_radius="@{50f}"
shape_mode="@{ShapeMode.OVAL}"
start_color="@{`#666aaa`}" />
<!--
drawable_def=""
drawable_checked=""
drawable_checkable=""
drawable_enabled=""
drawable_focus=""
drawable_pressed=""
drawable_selected=""
-->
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Click on me!"
android:textAllCaps="false"
android:textColor="@android:color/white"
drawable_def="@{@drawable/button_def}"
drawable_pressed="@{@drawable/button_pressed}" />
</LinearLayout>
</ScrollView>
</layout>