android - 图像调整大小停止工作 - ScaleDrawable,setCompoundDrawablesWithIntrinsicBounds

时间:2013-11-25 04:45:20

标签: android textview android-drawable android-bitmap

我有以下代码来调整图片大小:

int size = `textView.getLineHeight()`;
Drawable drawable =  caller.getResources().getDrawable(R.drawable.myDrawable);
drawable = new ScaleDrawable(drawable, 0, size, size).getDrawable();
drawable.setBounds(0, 0, size, size);
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0);

该代码工作没有问题并突然停止(图像未调整大小并以完整大小显示)。我甚至不确定是什么造成的。我99.99%肯定我没有改变代码中的任何内容。但是我重新组织了一些我的drawable文件夹。要么它以某种方式与某些文件有关,eclipse会自动定期下载。

总结如何调整图像大小以使其等于textView.getLineHeight()(请注意,使用两个视图ImageView和TextView在我的情况下不是一个好的解决方案,所以我更愿意关注如何调整位图本身的大小)。

0 个答案:

没有答案