简体   繁体   English

android padding-在4.2.2中有时会被忽略,在4.0.4中有效

[英]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.

相关问题 下拉菜单会忽略Android布局填充 - Android layout padding is ignored by dropdown 在Android 4.0.4中解析json时出现FileNotFoundException,但在Android 2.3.3中有效 - FileNotFoundException while parsing json in android 4.0.4 but works in android 2.3.3 更改方向时更改图像在android 4.0.4中不起作用,但在4.1.3中起作用 - change image on orientation change does not work in android 4.0.4 but works in 4.1.3 Android 2.3.3中的NotificationCompat破解,但在Android 4.2.2中运行良好 - NotificationCompat crack in Android 2.3.3 but works well in Android 4.2.2 有时在Android上忽略LD_LIBRARY_PATH - LD_LIBRARY_PATH ignored on Android sometimes Camera.open 适用于 Android 4.2.2,但在 6.0.1 上失败 - Camera.open works on Android 4.2.2, but fails on 6.0.1 广播接收器在不同版本的Android上的工作方式不同(4.1.1和4.2.2) - Broadcast receiver works differently on different Version of Android (4.1.1 & 4.2.2) Android代码在Gingerbread上运行良好,但在Nexus 7(含4.2.2)上无法正常运行 - Android code works fine on Gingerbread but breaks on Nexus 7 w/ 4.2.2 Android应用无法在4.2.2上安装。 但适用于新版本。 - Android app fails to install on 4.2.2. but works on newer versions. AsyncTask有时仅适用于Android - AsyncTask only works sometimes Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM