我有一个图像存储在数据库中作为blob,我将其恢复为Bitmap Image并将其放在textview中 这是我的代码
byte[]q_img=cur.getBlob(10);
Drawable qDrawable = new BitmapDrawable(ctx.getResources(),BitmapFactory.decodeByteArray(q_img,0,q_img.length));
question.setCompoundDrawablesWithIntrinsicBounds(null,null,qDrawable,null);
此代码完美运行并在textview中显示图像,但问题是某些图像的宽度大于TextView的宽度并且溢出宽度 所以我如何使图像的宽度适合相同宽度的textview
答案 0 :(得分:0)
试试这个,看它是否有效。
在layout_width="wrap_content"
文件中设置XML
或TextView txt= new TextView(context);
txt.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
使用java