android EditText 中加入联系人图片
如同来电通那样,发送短信的界面,在EditText搜索到 联系人的时候,会保存为一张view显示出来,并保存在EditText里面
android UI --------------------编程问答-------------------- LinearLayout layout = new LinearLayout(this);
TextView tv = new TextView(this);
String str = mEditSearch.getText().toString();
tv.setText(str);
layout.addView(tv);
layout.setBackgroundColor(Color.CYAN);
Bitmap bitmap = convertViewToBitmap(layout);
imageView.setImageBitmap(bitmap);
private void addBitmapToEdit(Bitmap bitmap) {
mImageSpan = new ImageSpan(this, bitmap);
mSpannableString = new SpannableString("p");
mSpannableString.setSpan(mImageSpan, 0, 1
, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mEditSearch.append(mSpannableString);
}
public static Bitmap convertViewToBitmap(View view){
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
} --------------------编程问答-------------------- 又是个水区 csdn真的不行了 --------------------编程问答--------------------
话说楼主搞定了没有 我也需要做这功能 求帮忙
补充:移动开发 , Android