Android TextView Button setPadding不起作用
来源:互联网 发布:美团外卖消费数据分析 编辑:程序博客网 时间:2024/06/04 23:39
代码说明: setBackgroundResource之后重新设置一下padding
一、折中办法
1.1 方法一
int bottom = theView.getPaddingBottom();
int top = theView.getPaddingTop();
int right = theView.getPaddingRight();
int left = theView.getPaddingLeft();
theView.setBackgroundResource(R.drawable.entry_bg_with_image);
theView.setPadding(left, top, right, bottom);
int top = theView.getPaddingTop();
int right = theView.getPaddingRight();
int left = theView.getPaddingLeft();
theView.setBackgroundResource(R.drawable.entry_bg_with_image);
theView.setPadding(left, top, right, bottom);
1.2 方法二
int pad = resources.getDimensionPixelSize(R.dimen.linear_layout_padding);
theView.setBackgroundResource(R.drawable.entry_bg_with_image);
theView.setPadding(pad, pad, pad, pad);
theView.setBackgroundResource(R.drawable.entry_bg_with_image);
theView.setPadding(pad, pad, pad, pad);
二、原帖网址
http://stackoverflow.com/questions/5890379/android-setbackgroundresource-discards-my-xml-layout-attributes
三、搜索关键字
GOOGLE:"android setbackgroundresource changes padding"
转自:http://www.cnblogs.com/over140/archive/2012/07/20/2600525.html
0 0
- Android TextView Button setPadding不起作用
- Android TextView setPadding 函数
- android 动态添加ImageView 设置setPadding不起作用问
- TextView android:drawablePadding 不起作用
- Android TextView setGravity不起作用
- Android LlistView +Button +TextView
- android组件 TextView Button
- 动态添加ImageView 设置setPadding不起作用问题
- 动态添加ImageView 设置setPadding不起作用问题
- Android中Button.setClickable(false)不起作用
- Android学习--TextView和Button
- Android---2---TextView、Button、EditText
- 动态setImageResource后setPadding无效不起作用的处理办法
- Android Button及TextView动态变换颜色
- Android学习笔记3 - Button & TextView
- android之TextVIew与Button交互
- android中设置TextView/Button 走马灯效果
- Android Button及TextView动态变换颜色
- 大数相乘
- 【基于node.js+express的web开发备忘】--nodejs v0.11.13 + express v4.2.0+mongodb v2.0.6
- Android 获取资源数据/文件
- 迭代器模式---学习笔记
- 八皇后问题
- Android TextView Button setPadding不起作用
- 拼链接 Oracle 截取部分字符
- Junit测试配置和使用
- ubuntu 配置NFS tftp
- jdbc查询数据库中数据
- Perl入门一,通过shell执行perl语句
- sqlite数据库之一创建
- JVM监控工具介绍jstack, jconsole, jinfo, jmap, jdb, jsta
- Method Swizzle黑魔法,修改 ios 系统类库方法