首页 > 编程知识 正文

安卓设计规范不断更新怎么办,安卓开发规范

时间:2023-05-05 14:05:49 阅读:226101 作者:4027

会不断补充有利于安卓开发的一些规范或者技巧!

一 建议使用Designtime属性

要使用designtime属性,首先要确保你的布局中定义了工具命名空间:xmlns:tools="http://schemas.android.com/tools"

工具命名空间是Android工具特别公认的命名空间,因此,当应用程序打包并且没有运行时开销时,所有在工具命名空间中的视图元素上定义的属性将被自动删除。

然后,例如设置文本字段的文本,使用与Android框架相同的属性,但使用 tools: 命名空间而不是 android: 命名空间:
        <TextView              android:text="Name:"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />
        <EditText               tools:text="John Doe"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />

这样开发时,我们可以看到布局,又不会影响到打包时带入到版本中

补充链接 http://tools.android.com/tips/layout-designtime-attributes


版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。