-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.aly
321 lines (288 loc) · 11.1 KB
/
layout.aly
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
{
ScrollView;
layout_width="fill",
layout_height="fill",
{
LinearLayout,
orientation="vertical",
layout_width="fill",
layout_height="fill",
padding="8dp";
id="mainLay";
--示例布局在《附》内,上面的都是测试布局
buildTitle("颜色测试 | Color test");
buildColorShow("强调色","Accent color",
"android.res.color.attr.colorAccent");
buildColorShow("文字主色的 ColorStateList 类型",
"ColorStateList type of the primary text color",
"android.res.colorStateList.attr.textColorPrimary",true);
buildColorShow("普通颜色资源","Normal color resources",
"res.color.seed");
buildColorShow("普通 ColorStateList 类型资源",
"Normal ColorStateList resources",
"res.colorStateList.mtrl_btn_stroke_color_selector",true);
buildColorShow("android 下的普通颜色资源",
"Normal color resources in android",
"android.res.color.holo_blue_light");
buildColorShow("actionBarStyle 主题的文字色",
"Primary text color of actionBarStyle",
"android.res(res.id.attr.actionBarStyle).color.attr.textColorPrimary");
buildColorShow("EMUI 主题强调色",
"EMUI accent color",
"android.res(androidhwext.R).color.emui_accent");
divider;buildTitle("主题测试 | Theme test");
isAndroidX and{
function(context)
return Toolbar(ContextThemeWrapper(context,res.id.attr.actionBarTheme))
end;
title="R.attr.actionBarTheme";
subtitle="res.id.attr.actionBarTheme : "..
res.id.attr.actionBarTheme;
};
divider;buildTitle("图片测试 | Drawable test");
buildBgShow("原生的 actionBarStyle 主题的背景",
"Background of system actionBarStyle",
"android.res(android.res.id.attr.actionBarStyle).drawable.attr.background");
buildBgShow("AndroidX 的 actionBarStyle 主题的背景",
"Background of actionBarStyle",
"res(res.id.attr.actionBarStyle).drawable.attr.background");
buildBgShow("EMUI 平板图片",
"EMUI pad image",
"res(androidhwext.R).drawable.img_device_pad");
divider;buildTitle("文字测试 | Text test");
buildValueShow("android.R.string.copy",
{"android.res.string.copy","android.res.text.copy"});
buildValueShow("R.string.abc_capital_off",
{"res.string.abc_capital_off","res.text.abc_capital_off"});
divider;buildTitle("布尔测试 | Boolean test");
buildValueShow("android.R.bool.config_showDefaultHome",
{"android.res.bool.config_showDefaultHome",
"android.res.boolean.config_showDefaultHome"});
divider;buildTitle("数字测试 | Boolean test");
buildValueShow("android.R.integer.config_shortAnimTime",
{"android.res.integer.config_shortAnimTime","android.res.int.config_shortAnimTime"});
buildValueShow("R.integer.hide_password_duration",
{"res.integer.hide_password_duration","res.int.hide_password_duration"});
buildValueShow("R.dimen.tooltip_margin",
{"res.dimen.tooltip_margin",
"res.dimension.tooltip_margin",
"res.dimensionPixelSize.tooltip_margin",
"res.dimensionPixelOffset.tooltip_margin"});
divider;buildTitle("缓存测试 | Cache test");
buildValueShow("R.color.mtrl_btn_stroke_color_selector",
{"res.colorStateList.mtrl_btn_stroke_color_selector",
"res.colorStateList.mtrl_btn_stroke_color_selector",
"res.colorStateList.mtrl_btn_stroke_color_selector",
"res.colorStateList.mtrl_btn_stroke_color_selector"});
buildValueShow("res.color",
{"res.color",
"res.color",
"android.res.color",
"android.res.color"});
buildValueShow("res.int",
{"res.int",
"res.int",
"android.res.int",
"android.res.int"});
buildValueShow("res.drawable",
{"res.drawable",
"res.drawable",
"android.res.drawable.sym_def_app_icon",
"android.res.drawable.sym_def_app_icon"});
buildValueShow("res:getOrNewResWithStyle(res.id.attr.actionBarStyle)",{
"res:getOrNewResWithStyle(res.id.attr.actionBarStyle)",
"res:getOrNewResWithStyle(res.id.attr.actionBarStyle)",
"res(res.id.attr.actionBarStyle)",
"res(res.id.attr.actionBarStyle)",
"res.getOrNewResWithStyle(android.res,android.res.id.attr.actionBarStyle)",
"res.getOrNewResWithStyle(android.res,android.res.id.attr.actionBarStyle)",
"android.res(android.res.id.attr.actionBarStyle)",
"android.res(android.res.id.attr.actionBarStyle)"});
buildValueShow("res.getOrNewResWithRClass(rClass)",
{"res.getOrNewResWithRClass(androidhwext.R)",
"res.getOrNewResWithRClass(androidhwext.R)",
"res(androidhwext.R)",
"res(androidhwext.R)",
"res.getOrNewResWithRClass(luajava.bindClass(\"com.google.android.material.R\"))",
"res.getOrNewResWithRClass(luajava.bindClass(\"com.google.android.material.R\"))",
"res(luajava.bindClass(\"com.google.android.material.R\"))",
"res(luajava.bindClass(\"com.google.android.material.R\"))"});
buildValueShow("res:clearCache()",{
"res.color",
"res:clearCache()",
"res.color",
"res(androidhwext.R).color",
"res.clearCache(res(androidhwext.R))",
"res(androidhwext.R).color",
"android.res.drawable.sym_def_app_icon",
"res.clearCache(android.res)",
"android.res.drawable.sym_def_app_icon"});
--附录
divider;buildTitle("附1:常见示例 | Common demo");
{
TextView,
text="强调色\nAccent color",
textColor=android.res.color.attr.colorAccent;
layout_width="fill",
padding="4dp";
},
{
TextView,
text="暗色主色 / 状态栏颜色\nPrimary color / status bar color",
textColor=android.res.color.attr.colorPrimaryDark;
layout_width="fill",
padding="4dp";
},
{
TextView,
text="文字主色的 ColorStateList 类型\nColorStateList type of the primary text color",
textColor=android.res.colorStateList.attr.textColorPrimary;
layout_width="fill",
padding="4dp";
},
--以下内容仅支持 Material3 的编辑器可用,为了兼容原版Android,使用了 isAndroidX 选择性显示下面的东西
--请在使用时请删除 `isAndroidX and` 和 `or nil`
--注意:主要色、次要色、第三级颜色不一样,AndroidX为了统一,改成一样的了。详情: https://zhuanlan.zhihu.com/p/460081776
isAndroidX and divider or placeholderView;
isAndroidX and buildTitle("附2:常见 Material 3 示例 | Common Material 3 demo") or placeholderView;
isAndroidX and {
TextView,
text="主要色\nPrimary color",
textColor=res.color.attr.colorOnPrimary;
backgroundColor=res.color.attr.colorPrimary;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="主要容器色\nPrimary container color",
textColor=res.color.attr.colorOnPrimaryContainer;
backgroundColor=res.color.attr.colorPrimaryContainer;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="次要色\nSecondary color",
textColor=res.color.attr.colorOnSecondary;
backgroundColor=res.color.attr.colorSecondary;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="次要容器色\nSecondary container color",
textColor=res.color.attr.colorOnSecondaryContainer;
backgroundColor=res.color.attr.colorSecondaryContainer;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="第三级色\nTertiary color",
textColor=res.color.attr.colorOnTertiary;
backgroundColor=res.color.attr.colorTertiary;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="第三级容器色\nTertiary container color",
textColor=res.color.attr.colorOnTertiaryContainer;
backgroundColor=res.color.attr.colorTertiaryContainer;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="错误色\nError color",
textColor=res.color.attr.colorOnError;
backgroundColor=res.color.attr.colorError;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="错误容器色\nError container color",
textColor=res.color.attr.colorOnErrorContainer;
backgroundColor=res.color.attr.colorErrorContainer;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="表面色\nSurface color",
textColor=res.color.attr.colorOnSurface;
backgroundColor=res.color.attr.colorSurface;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="变种表面色\nVariant surface color",
textColor=res.color.attr.colorOnSurfaceVariant;
backgroundColor=res.color.attr.colorSurfaceVariant;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="背景色\nBackground color",
textColor=res.color.attr.colorOnBackground;
backgroundColor=android.res.color.attr.colorBackground;
layout_width="fill",
padding="4dp";
} or placeholderView,
isAndroidX and {
TextView,
text="边框色\nOutline color",
backgroundColor=res.color.attr.colorOutline;
layout_width="fill",
padding="4dp";
} or placeholderView,
isSdk31AndUp and divider or placeholderView;
isSdk31AndUp and buildTitle("附3:Android 12 壁纸取色示例 | Android 12 wallpaper color demo") or placeholderView;
isSdk31AndUp and {
TextView,
text="系统强调色1\nSystem accent color 1",
textColor=android.res.color.system_accent1_50;
backgroundColor=android.res.color.system_accent1_600;
layout_width="fill",
padding="4dp";
} or placeholderView,
isSdk31AndUp and {
TextView,
text="系统强调色2\nSystem accent color 2",
textColor=android.res.color.system_accent2_50;
backgroundColor=android.res.color.system_accent2_600;
layout_width="fill",
padding="4dp";
} or placeholderView,
isSdk31AndUp and {
TextView,
text="系统强调色3\nSystem accent color 3",
textColor=android.res.color.system_accent3_50;
backgroundColor=android.res.color.system_accent3_600;
layout_width="fill",
padding="4dp";
} or placeholderView,
isSdk31AndUp and {
TextView,
text="系统中立色1\nSystem neutral color 1",
textColor=android.res.color.system_neutral1_50;
backgroundColor=android.res.color.system_neutral1_600;
layout_width="fill",
padding="4dp";
} or placeholderView,
isSdk31AndUp and {
TextView,
text="系统中立色2\nSystem neutral color 2",
textColor=android.res.color.system_neutral1_50;
backgroundColor=android.res.color.system_neutral2_600;
layout_width="fill",
padding="4dp";
} or placeholderView,
--更多颜色请查看 Android 12 自带的彩蛋
divider;buildTitle("耗时 | Time consuming");
}
}