[英]android padding - sometimes ignored in 4.2.2, works in 4.0.4
I use padding in one of my layouts. 我在一种布局中使用填充。 More precisely it's a component defining one item which I use in two different list views in my application. 更确切地说,它是一个定义一项的组件,我在应用程序的两个不同列表视图中使用了该组件。 Today when preparing the new version of my program, I noticed very strange thing. 今天,在准备程序的新版本时,我注意到了非常奇怪的事情。
Padding works without problems in android 4.0.4 (in case of two list views). 填充工作在android 4.0.4中没有问题(在两个列表视图的情况下)。 Padding seems to be ignored in first list view, and works ok in the second list view in android 4.2.2. 填充似乎在第一个列表视图中被忽略,并且在android 4.2.2中的第二个列表视图中工作正常。
Moreover I didn't touch this layout definition since many days so it's quite surprising it stopped to work. 而且,由于很多天以来我都没有触及这个布局定义,所以令人惊讶的是它停止工作了。 Android bug? Android bug? Eclipse bug? Eclipse错误?
I tried to clean project, restart eclipse etc. Nothing helps... 我试图清理项目,重新启动eclipse等。没有任何帮助...
Any ideas? 有任何想法吗?
FInally I've found the reason - In case of one of listviews
I use setBackgroundResource
and it seems that Android here has a bug....: 最后,我已经找到了原因-如果是listviews
之一,我将使用setBackgroundResource
,并且看来Android此处存在错误。...:
The solution which helped: 该解决方案有助于:
if(condition) {
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);
}
more: setBackgroundResource() discards my XML layout attributes 更多: setBackgroundResource()丢弃我的XML布局属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.