gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:02:17 28 4
gpt4 key购买 nike

我在我的一个布局中使用了内边距。更准确地说,它是一个定义一个项目的组件,我在我的应用程序的两个不同 ListView 中使用它。今天在准备我的程序的新版本时,我注意到了一件很奇怪的事情。

填充在 android 4.0.4 中没有问题(在两个 ListView 的情况下)。填充似乎在第一个 ListView 中被忽略,并且在 android 4.2.2 的第二个 ListView 中工作正常。

此外,我已经很多天没有碰过这个布局定义了,所以它停止工作真是令人惊讶。安卓漏洞? Eclipse 错误?

我尝试清理项目、重启 eclipse 等。没有任何帮助...

有什么想法吗?

最佳答案

最后我找到了原因 - 如果是 listviews 之一,我使用 setBackgroundResource 并且这里的 Android 似乎有一个错误......:

有帮助的解决方案:

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

更多:setBackgroundResource() discards my XML layout attributes

关于android padding - 有时在 4.2.2 中被忽略,在 4.0.4 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22353525/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com