前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >小trick之tools

小trick之tools

作者头像
夏洛克的猫
发布2018-10-18 14:23:39
3790
发布2018-10-18 14:23:39
举报
文章被收录于专栏:移动开发移动开发

以前写布局时为了观看布局效果,会写些静态的测试数据,以便在androidstudio中观察布局的效果.等到写完布局的时候在进行擦除.当布局很多的时候,这确实也是很费劲的事.其实官方早就为我们考虑到这点了. 我们在实际开发中可以使用tools. tools可以覆盖我们的属性,但是运行时这些属性是被忽略的

如:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    tools:context="com.xf.mylab.activity.AniTestActivity">

    <Button
        android:id="@+id/start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="start"
        tools:text="TEST"/><!--tools的属性会直接在编辑中看到效果,而在不会在运行时起效果-->

    <Button
        android:id="@+id/end"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="end"
        tools:text="TEST"/>

</LinearLayout>

as中预览的效果:

**这里写图片描述**
**这里写图片描述**

实际运行时的效果:

这里写图片描述
这里写图片描述

tools对其他的属性都是支持的,实际运用时只要把android:替换成tools:即可,不需要手动擦除,这对提高我们工作效率还是有帮助的.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年09月04日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档