星空网 > 软件开发 > 操作系统

日常记录

 

  近日,在开发过程中 遇到了 Layout 代码中设置 Background 后,padding失效的问题,只是在Android 4.4.4 和 4.4.2 的手机上遇到了。

网上搜索了下,说是 4.4 系统里的一个bug,解决方法就是 在动态设置 Background 后,重新设置 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);

 

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);

 

原帖网址

原标题:日常记录

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

国际速递快运:https://www.goluckyvip.com/tag/101623.html
速递国际快运:https://www.goluckyvip.com/tag/101624.html
国际邮递:https://www.goluckyvip.com/tag/101626.html
国际货运实务:https://www.goluckyvip.com/tag/101627.html
ewe国际物流官网:https://www.goluckyvip.com/tag/101628.html
ems国际快递几天能到:https://www.goluckyvip.com/tag/101629.html
温州旧货市场有玻璃柜卖吗?:https://www.vstour.cn/a/411246.html
如何用摄影作品表现“芳草鲜美,落英缤纷”的:https://www.vstour.cn/a/411247.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流