包裹文字的Andr​​oid图像包裹、图像、文字、Andr

2023-09-05 10:37:52 作者:咕嘟咕嘟热狗肠

我想插入图像插入文字,例如:

I would like to insert image into text, for example:

我想显示的文字likie这样的:

I would like to show the text likie this:

要编辑的图片,你应该点击[图]按钮。

"To edit picture you should click on" [image] "button."

其中[图片]是真实的图像(如ImageView的)

Where [image] is real image (e.g. ImageView)

推荐答案

你可以试试这个,我DONOT知道这是不是你的需要:

you can try this,i donot know if this is your need:

   setContentView(R.layout.main); 
            TextView textView  = (TextView) findViewById(R.id.textview); 
            SpannableString ss = new SpannableString("abc"); 
            Drawable d = getResources().getDrawable(R.drawable.icon32); 


            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); 
            ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE); 
            ss.setSpan(span, 0, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); 


            textView.setText(ss);