Android 动态的给Button、TextView、ImageView等控件设置了background后,再设置padding属性时该属性不起作用
2014-05-20 10:13
996 查看
也许大家遇到这样一个问题,有时我们根据业务需要在一个ViewGroup中动态的(程序运行过程中)添加View。例如添加Button,就需要给Button添加background、padding、margin等属性。
但是当程序运行时一个很奇怪的问题出现了。如果padding设置在background之前则该属性不起作用,如果padding设置在background之后则运行正常。
具体是什么原因我现在也不太明白,希望明白人能够贴出来分享一下。
但是当程序运行时一个很奇怪的问题出现了。如果padding设置在background之前则该属性不起作用,如果padding设置在background之后则运行正常。
具体是什么原因我现在也不太明白,希望明白人能够贴出来分享一下。
相关文章推荐
- android 动态添加ImageView 设置setPadding不起作用问
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性加入图标
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox
- 安卓学习笔记(一)Android ImageButton、ImageView控件属性设置 图片显示问题
- 动态添加ImageView 设置setPadding不起作用问题
- 【android】解决设置ImageView的scaletype为centerCrop后padding不起作用的办法
- 系出名门Android(5) – 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox
- Android控件——TextView、EditText、ImageView、Button、ImageButton
- Android - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock 的简单介绍
- Android代码生成TextView,Button,CheckBox等控件的设置技巧
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, Ra
- android Button,textView 等控件设置控件内嵌周围图片使用方法
- 动态添加ImageView 设置setPadding不起作用问题
- 解决Android当中GridView的Item子控件中有ImageView图片大小不一致问题,动态设置ImageView控件大小
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox
- Android 代码里动态设置TextView/Button等的文字颜色Seletor