Android 是否可以重新绘制imagespan?

Android 是否可以重新绘制imagespan?,android,Android,是否可以在编辑文本框中放置新位图的情况下绘制图像范围。 似乎没有任何接口,所以我不确定如何使用。 我尝试将图像跨度设置为指向新构建的位图,但似乎不起作用 下面是我第一次用来分配图像跨度的代码片段: 我基本上希望在点击span时使用新图标“R.drawable.Icon2”重新绘制位图: Button background = new Button(tv.getContext()); background.setTextSize(getResources().getDimensio

是否可以在编辑文本框中放置新位图的情况下绘制图像范围。 似乎没有任何接口,所以我不确定如何使用。 我尝试将图像跨度设置为指向新构建的位图,但似乎不起作用

下面是我第一次用来分配图像跨度的代码片段: 我基本上希望在点击span时使用新图标“R.drawable.Icon2”重新绘制位图:

    Button background = new Button(tv.getContext());
    background.setTextSize(getResources().getDimension(
    R.dimen.default_font_size));
    background.setCompoundDrawablesWithIntrinsicBounds(R.drawable.Icon1, 0, 0, 0);
    background.setText(chip.toString());

    BitmapDrawable bmd = new BitmapDrawable(loadBitmapFromView(background));
    bmd.setBounds(0, 0, bmd.getIntrinsicWidth(),bmd.getIntrinsicHeight());
    final ImageSpan imgSpan=new ImageSpan(bmd, chip.toString());
    chip.setSpan(imgSpan,0,chip.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

旁注:span也是一个可单击的span,因此它有一个onClick()方法。

不要使用ImageSpan,而是使用DynamicDrawableSpan。ImageSpan不是从DynamicDrawableSpan派生的吗?使用它的好处是什么?好吧,似乎ImageSpan接受任何可绘制文件,不仅像我想的那样是BitmapDrawable,所以你可以使用ImageSpan,但是如果使用LevelListDrawable或StateListDrawable,它们都可以作为一个动态容器来容纳子可绘制文件