1 Star 0 Fork 4

meepobrother/astator.examples

forked from astator/astator.examples 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
04.ui控件预览.cs 4.41 KB
一键复制 编辑 原始数据 按行查看 历史
yiszza 提交于 2022-04-30 14:48 . Update for astator.0.4.0
using Android.Graphics;
using astator.Core.Script;
using astator.Core.UI.Base;
namespace Examples;
public class Test
{
[ScriptEntryMethod(FileName = "04.ui控件预览.cs", IsUIMode = true)]
public static void Main(ScriptRuntime runtime)
{
DefaultTheme.ColorPrimary = Color.Teal;
var xml =
@"
<linear orientation='vertical'>
<card bg='#444f7d'>
<text margin='10,0' h='60' text='ui控件预览' textColor='#000000' textSize='22' textStyle='bold' gravity='center'/>
</card>
<scroll>
<linear orientation='vertical'>
<text text='文本控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<text text='普通文本' textSize='16' margin='20,5'/>
<text text='加粗文本' textSize='16' textStyle='bold' margin='20,5'/>
<text text='加粗斜体文本' textSize='16' textStyle='bold|italic' margin='20,5'/>
<text autoLink='web' text='超链接文本: https://www.baidu.com' textSize='16' margin='20,5'/>
<edit hint='我是编辑框提示' textSize='16' w='240' margin='20,5'/>
<text text='按钮控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<btn text='按钮' margin='20,5'/>
<btn text='透明按钮' bg='#00ffffff' margin='20,5'/>
<btn text='圆角按钮' bg='#e2a3a3' margin='20,5' radius='15'/>
<btn id='btn' text='点我' w='200' bg='#b9a2b0' margin='20,5'/>
<text text='图片控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<img src='appicon.png' w='50' h='50' margin='20,5' />
<img src='appicon.png' radius='25' w='50' h='50' margin='20,5' />
<text text='复选框控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<check checked='true' text='默认颜色' margin='20,0'/>
<check checked='true' text='修改状态框颜色' color='#e2a3a3' margin='20,0'/>
<check checked='true' text='修改状态框和文本颜色' color='#e2a3a3' textColor='red' margin='20,0'/>
<text text='开关控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<switch checked='true' text='默认颜色' margin='20,0'/>
<switch checked='true' text='修改按钮颜色' color='#e2a3a3' w='240' margin='20,0'/>
<switch checked='true' text='修改按钮和文本颜色' color='#e2a3a3' textColor='red' w='240' margin='20,0'/>
<text text='单选框控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<radioGroup orientation='vertical' position='1' margin='20,5'>
<radio text='选项1'/>
<radio text='选项2'/>
<radio text='选项3'/>
<radio text='选项4'/>
</radioGroup>
<radioGroup orientation='horizontal' position='3' margin='20,5'>
<radio color='#e2a3a3' text='选项1'/>
<radio color='#e2a3a3' text='选项2'/>
<radio color='#e2a3a3' text='选项3'/>
<radio color='#e2a3a3' text='选项4'/>
</radioGroup>
<text text='下拉框控件:' textSize='18' textStyle='bold' margin='10,15,0,5'/>
<spinner entries='选项1|选项2|选项3|选项4' position='2' margin='20,0'/>
<spinner textColor='red' entries='选项1|选项2|选项3|选项4' position='1' margin='20,0'/>
<web h='500' url='https://astator.gitee.io/docs/#/quickstart'/>
</linear>
</scroll>
</linear>";
//解析xml
var layout = runtime.Ui.ParseXml(xml);
runtime.Ui.Show(layout);
//设置状态栏颜色
runtime.Ui.SetStatusBarColor("#444f7d");
//设置状态栏深色字体图标
runtime.Ui.SetLightStatusBar();
//添加单击事件
runtime.Ui["btn"].On("click", new OnClickListener((v) =>
{
var btn = v as IView;
var text = btn.GetAttr("text");
btn.SetAttr("text", $"{text}!");
}));
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/meepo_vip/examples.git
git@gitee.com:meepo_vip/examples.git
meepo_vip
examples
astator.examples
main

搜索帮助