索尼Xperia S(LT26i)似乎没有显示复合绘图

时间:2014-08-22 08:34:42

标签: android sony sony-xperia compound-drawables

我们正在测试我们的新应用,我们将复合drawable用于多个textview。不幸的是索尼Xperia S(LT26i)忽略了setCompoundDrawables& setCompoundDrawablesWithIntrinsicBounds。

有人能证实这个错误吗?或者有人有工作的解决方法吗?这种效果会影响其他手机吗?

谢谢和问候

2 个答案:

答案 0 :(得分:3)

我可以在LT26i / 4.1.2 / build 6.2.B.1.96上确认相同的行为。

我的解决方法是在重新分配适当的drawables之前清除所有复合drawable:

final int oldPadding = getCompoundDrawablePadding();

// In order to be able to reset the drawables, set padding to zero.
// (this step is specific to this Android issue/bug)
setCompoundDrawablePadding(0);
// Reset drawables
setCompoundDrawables(null, null, null, null);

// Set drawables and restore padding
setCompoundDrawables(myDrawables[0], myDrawables[1], myDrawables[2], myDrawables[3]);
setCompoundDrawablePadding(oldPadding);

答案 1 :(得分:3)

我在Xperia S(LT26i)上也发现了相同的行为。 我在几个不同的设备上尝试过,包括其他4.1.2设备,它是唯一一个有错误的设备。 我修改了Melv的答案(非常感谢,我不知道为什么会这样!)

TextView title = ....

title.setCompoundDrawablePadding(0);
// Reset drawables
title.setCompoundDrawables(null, null, null, null);
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, drawableId, 0);