Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

感觉写xml属性太多了,建议改成类似 css 那样的 #29

Closed
01haike opened this issue May 30, 2019 · 3 comments
Closed

感觉写xml属性太多了,建议改成类似 css 那样的 #29

01haike opened this issue May 30, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@01haike
Copy link

01haike commented May 30, 2019

感觉写xml属性太多了,建议改成类似 css 那样的。2333

@nmgwddj nmgwddj added the enhancement New feature or request label May 30, 2019
@nmgwddj
Copy link
Collaborator

nmgwddj commented May 31, 2019

对于 XML 来说,设置属性例如下代码

<Button width="100" height="30" margin="10,10,10,10" text="TestButton" normaltextcolor="darkcolor" />

对于 CSS 来说

Button {
	width: 100px;
	height: 30px;
	margin: 10px;
	color: #222;
}

除了 Button text 的定义可能不一样以外,其他基本都是类似的,XML 中控件支持的属性远没有 CSS2 的特性支持要多,CSS3 就更加多种多样了。如果您还认为 XML 的属性太多,或者您更倾向于使用 CSS 方式来定义控件的样式,也欢迎您开启一个分支提交一些基础结构代码,来一起完善类似功能。

@01haike
Copy link
Author

01haike commented May 31, 2019

<RichEdit class="te_simple_edit te_simple_edit_color" name="password" prompttext="Password" promptcolor="dark_gray" password="true" font="1" width="stretch" height="25" bordersize="1" bordercolor="te_border_color" margin="0,5,0,0" borderround="6,6"></RichEdit>

比如这样的 xml 就有点多。xml 还容易出错,不易读,如果界面复杂一些的话,会有很多嵌套。并且改的时候把tag 不小心删掉会导致加载失败。不容易排错。
当然了,xml这种方式比自绘控件强太多了。

@01haike 01haike closed this as completed May 31, 2019
@nmgwddj
Copy link
Collaborator

nmgwddj commented May 31, 2019

从使用上您可以用一些功能丰富的 XML 编辑器,比如 notepad++、VisualStudio 的文本编辑器都是很好的 XML 文件编辑工具。这些编辑器在出现缺少关键字或者语法错误的时候都会有相应的界面提示。
另外您也可以在定义自定义全局 class 属性放到 global.xml 中,这样就不会产生大量重复的样式代码了。这类似 LESS 语法中的全局变量,方法都是可以变通的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants