1.tools:attribute
如果你需要查看写的TextView在有文字时候的预览情况。那么这个就是为你准备的。使用'tools:something="value"'
这个值会显示在预览时候,但是在软件真正运行的时候不会出现这个内容。
只需要二步就可以:
- 在根布局中添加
xmlns:tools="[http://schemas.android.com/tools](http://schemas.android.com/tools)"
- 在TextView中使用
'tools:something="value"'
属性
(这个太有用了!!!我以前每次写布局预览效果都用android:text = "XXX",然后程序弄完还得去删。太傻了!!!)
2.Extract Resource
比如你在布局文件或者代码文件中直接写了某个String字符串或者某个dimen数值,而不是引用资源文件,那难道还要我再去打开相应的String.xml或者dimen.xml文件去添加,然后这边的布局文件或者代码文件中再去修改使用引用?答案当然是NO。
Mac:选中那个值,然后option+enter键选择Extract String/Dimension Resource 。
Win: alt+enter键选择Extract String/Dimension Resource 。
![](https://i-blog.csdnimg.cn/blog_migrate/52e5e6a4b8824832832874d21d87b35a.webp?x-image-process=image/format,png)
3.将一个本地变量抽取为全局变量,将鼠标定位在要抽取为全局变量的本地变量上,按Ctrl + Alt + F(Windows/Linux上)