使用xml写一个关于textSize的selector
来源:互联网 发布:使用数组储存1825 编辑:程序博客网 时间:2024/06/18 14:47
本身并没有这样的方法。selector作为根标签只能在animator和drawable资源文件夹下使用。
step1:既然能在animator下创建,那么就用属性动画把字体大小从一个值变到另一个值,不也能达到想要的效果。
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true"> <set> <objectAnimator android:duration="200" android:propertyName="textSize" android:valueFrom="4dp" android:valueTo="4.8dp" android:valueType="floatType"/> </set> </item> <item android:state_selected="false"> <set> <objectAnimator android:duration="200" android:propertyName="textSize" android:valueFrom="4.8dp" android:valueTo="4dp" android:valueType="floatType"/> </set> </item></selector>
PS:这里不知为啥4dp的实际效果类似与12dp。
step2:在style中使用该selector。
<?xml version="1.0" encoding="utf-8"?><resources> <style name="text_style"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">@drawable/selector_text_color</item> <item name="android:stateListAnimator">@animator/selector_text_size</item> </style></resources>但是android:stateListAnimator属性只能在values-v21及以上中使用,21以下版本可以另外指定textSize一个固定值。
<style name="text_style"><item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">@drawable/selector_text_color</item><item name="android:textSize">12dp</item> </style>step3:在textView或者其他控件中引用该style。
阅读全文
0 0
- 使用xml写一个关于textSize的selector
- 关于selector的使用
- android 写 selector.xml 时的注意事项
- Android 关于Selector的使用
- 关于在代码中设置TextView的textSize
- Android中关于Selector的使用
- android关于selector和shape的使用
- 关于imageview中selector的使用
- 自己写的一个ant使用build.xml
- 自己写的一个ant使用build.xml
- Android关于selector.xml用法的一点小结
- 关于selector中图片显示的一个小问题
- Selector的一个坑
- 关于android的selector
- 写TextView的Selector了解到的android读取xml文件的几点规则
- 关于selector的使用,非常全的文章。
- 使用java nio的selector做一个数据查询主机
- selector用法中关于不同控件使用不同的state
- 五:第一个Hello World程序
- qt读中文乱码
- poj1631 Bridging signals(同51Nod1134)
- caffe练习
- 微信公众号文章的爬取(搜狗微信搜索)
- 使用xml写一个关于textSize的selector
- hadoop环境搭建
- 物联网专业术语
- 模板为什么不支持分离编译
- 神经网络总结
- javawebday23(request 看你的浏览器和ip)
- Python小白白学习篇之文件与异常
- 走进Spark生态圈:运行程序在Spark集群
- 406. Queue Reconstruction by Height