android tools是干什么的,Android 冷兵器 之 tools

本文介绍了Android开发中tools命名空间的使用,包括预览UI、避免测试内容打包、支持列表预览等功能。通过tools,可以在XML布局中实现预览效果,而这些内容不会出现在最终的apk中。此外,还展示了如何预览RecyclerView、ListView和GridView,以及如何设置列表数据和自定义sample数据。
摘要由CSDN通过智能技术生成

前言

Android开发在所难免的就是UI的预览和调整,一般情况下都是直接run看效果,或者是使用AS的preview预览,但这同样带来个小问题,就是你的测试内容会跟随着代码被打包到apk中,如果没做容错的处理很有可能将测试内容展示给用户。

还有就是像一些列表是不支持预览效果的,比如ListView。

其实Android老早就有tools命名空间,作为一个开发快到一年的我,最近看到一篇文章才发现这个tools大用处,在此做个笔记。

直接看一下效果,最为清楚:

52ba7800d3b9

RecyclerView.gif

52ba7800d3b9

ListView 预览.png

52ba7800d3b9

GridView 预览.png

XML中的代码区区几行,但是右侧的preview效果却很直接,还有就是这些数据并不会打到apk中,直接运行是没有任何效果的,这就是厉害之处!相关代码已提交到Github上: Android Tools

初步使用

既然是命名空间,那肯定就要在XML开头就要声明。

xmlns:tools="http://schemas.android.com/tools"

类似于

xmlns:android="http://schemas.android.com/apk/res/android"

然后就可以使用tools的相关属性了。属性功能很多很全,我就介绍一下常用的,文尾会贴上相关的文章链接。

View 相关

先从view相关说起,在XML中view的android任意属性值,可以直接替换成tools,这样就可以实现实时的预览效果,并且正式部署之后不会展示。有点类似于dataBinding中的 def

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
README for preparing SD/MMC/Micro-SD CARD for booting Android Pre-Requesites -------------- 1) Need to have an SD/MMC/Micro-SD card with atleast 2GB of size. 2) The script needs to be invoked from ubuntu linux machine 8.04 or above. 3) User needs to have sudo privileges. What script will do ------------------- The mkmmc-android.sh partitions the MMC/SD card into three partiions namely boot, rootfs and data. The script will then put the boot images on boot partition and extracts the android rootfs-rootfs_*.tar.bz2 to rootfs partition. Finally the script will copy the Media clips to the data partition and START_HERE folder to boot partition. How to invoke the script ------------------------ There are three ways of invoking this script. 1) Command: sudo ./mkmmc-android <device> <MLO> <u-boot.bin> <uImage> <boot.scr> <rootfs tar.bz2 > <Media_Clips> <START_HERE Location> Example: sudo ./mkmmc-android /dev/sdc MLO u-boot.bin uImage boot.scr rootfs.tar.bz2 Media_Clips Details: In this case, the script will take Boot Images (MLO,u-boot.bin, uImage and boot.scr) Root Filesystem tarball, Media Clips and START_HERE folder as arguements. The script will then put the boot images on boot partition, extract the android rootfs-rootfs_*.tar.bz2 to rootfs partition. Finally the script will copy the Media clips to the data partition and START_HERE folder to boot partition. 2) Command: sudo ./mkmmc-android <device> <MLO> <u-boot.bin> <uImage> <boot.scr> <rootfs tar.bz2 > Example: sudo ./mkmmc-android /dev/sdc MLO u-boot.bin uImage boot.scr rootfs.tar.bz2 Details: In this case, the script will take Boot Images (MLO,u-boot.bin, uImage and boot.scr) and Root Filesystem tarball as arguements. The script will then put the boot images on boot partition, extract the android rootfs-rootfs_*.tar.bz2 to rootfs partition. The data partiton will be left empty in this case. 3) Command: sudo ./mkmmc-android.sh <device> Example: sudo ./mkmmc-android.sh /dev/sdc Details: In this case, the script will assume default locations for BootImages, Root Filesystem, Media_Clips and START_HERE. This command is equivalent to the following sudo ./mkmmc-android /dev/sdc Boot_Images/MLO Boot_Images/u-boot.bin Boot_Images/uImage Boot_Images/boot.scr Filesystem/rootfs.tar.bz2 Media_Clips START_HERE If you are in a particular Board Specific Directory, extracted from DevKit Release, then you can prepare the sd card by executing sudo ./mkmmc-android.sh <device>, to prepare sd card.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值