关于TextView的一些学习
来源:互联网 发布:缺少对象 js 编辑:程序博客网 时间:2024/05/29 02:08
<TextView
android:id="@+id/homepage_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/btn_home_footbar_bg" //背景色
android:drawableTop="@drawable/home_icon_recommend_normal" //在文字上面显示的图片资源id
android:gravity="center" //居中
android:text="@string/recommend"
setCompoundDrawables 画的drawable的宽高是按drawable.setBound()设置的宽高,所以才有The Drawables must already have had setBounds(Rect) called.这句话之说。
而setCompoundDrawablesWithIntrinsicBounds是画的drawable的宽高是按drawable固定的宽高,即通过getIntrinsicWidth()与getIntrinsicHeight()获得,所以才有The Drawables' bounds will be set to their intrinsic bounds.这句话之说!
android:id="@+id/homepage_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/btn_home_footbar_bg" //背景色
android:drawableTop="@drawable/home_icon_recommend_normal" //在文字上面显示的图片资源id
android:gravity="center" //居中
android:text="@string/recommend"
android:textColor="@color/gray2_color" />
home_icon_recommend_normal
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_window_focused="false" android:drawable="@drawable/home_bg_nav_normal"></item> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/home_bg_nav_pressed"></item> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/home_bg_nav_pressed"></item> <item android:state_selected="true" android:drawable="@drawable/home_bg_nav_pressed"></item> <item android:state_focused="true" android:drawable="@drawable/home_bg_nav_pressed"></item></selector>
TextView 的setCompoundDrawablesWithIntrinsicBounds与setCompoundDrawables的区别
我做了一个测试,大概推出这样的结论:
setCompoundDrawables 画的drawable的宽高是按drawable.setBound()设置的宽高,所以才有The Drawables must already have had setBounds(Rect) called.这句话之说。
而setCompoundDrawablesWithIntrinsicBounds是画的drawable的宽高是按drawable固定的宽高,即通过getIntrinsicWidth()与getIntrinsicHeight()获得,所以才有The Drawables' bounds will be set to their intrinsic bounds.这句话之说!
private TextView mTV;
homepageNormal = getResources().getDrawable(R.drawable.home_icon_recommend_normal);
textColorNormal = getResources().getColor(R.color.gray);
mTV.setSelected(false);
mTV.setTextColor(textColorNormal);
mTV.setCompoundDrawablesWithIntrinsicBounds(null, homepageNormal, null, null);
0 0
- 关于TextView的一些学习
- 关于android中的一些textview的span
- 关于TextView的一些特殊处理
- 关于TextView的一些初步讲解
- 【TextView】Android TextView显示省略号的问题(关于TextView maxLength 和maxEms的学习)
- Android中关于TextView的一些小常识
- TextView的一些使用
- textView 的一些方法
- 关于TextView的一些高级应用及EditText的一些高级属性
- 关于学习的一些建议
- 关于Attribute的一些学习
- 关于学习的一些思考
- 关于学习的一些想法
- 关于学习的一些思考
- 关于浮动的一些学习
- 关于 explicit 的一些学习
- 关于学习的一些思考
- 关于学习的一些思考
- eclipse中配置javap
- Android ActionBar 一步一步分析
- Android中onItemLongClick和onCreateContextMenu的搭配使用实现SQLite增删改查
- 用notepad++编写html文件时,中文出现乱码解决办法
- maven3实战之仓库(maven仓库介绍)
- 关于TextView的一些学习
- LeetCode Linked List Cycle
- 日本空手道美女走红 堪称现实版春丽
- maven3实战之仓库(远程仓库的配置)
- linux安装flashplayer
- findbugs配置
- cocos2d-x 3.0rc0系列教程--(1)环境搭建
- Facebook利用苹果和谷歌弱点打造出亿级业务
- Xcode升级到5.1后,一些静态库.a文件编译报错