如同来电通那样,发送短信的界面,在EditText搜索到 联系人的时候,会保存为一张view显示出来,并保存在EditText里面androidUI

解决方案 »

  1.   

    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;
        }
      

  2.   

    又是个水区  csdn真的不行了