本文整理了Java中android.widget.TextView.destroyDrawingCache()
方法的一些代码示例,展示了TextView.destroyDrawingCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.destroyDrawingCache()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:destroyDrawingCache
暂无
代码示例来源:origin: TommyLemon/APIJSON
@Override
public void onDestroy() {
if (leftMenu != null) {
leftMenu.destroyDrawingCache();
leftMenu = null;
}
if (rightMenu != null) {
rightMenu.destroyDrawingCache();
rightMenu = null;
}
super.onDestroy();
}
代码示例来源:origin: TommyLemon/APIJSON
@Override
public void onDestroy() {
if (leftMenu != null) {
leftMenu.destroyDrawingCache();
leftMenu = null;
}
if (rightMenu != null) {
rightMenu.destroyDrawingCache();
rightMenu = null;
}
super.onDestroy();
}
代码示例来源:origin: stackoverflow.com
EditText editText = (EditText) findViewById(R.id.editText);
TextView textView = new TextView(this.getApplicationContext());
textView.setTypeface(editText.getTypeface());
textView.setText(editText.getText());
textView.measure(
View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
textView.setDrawingCacheEnabled(true);
textView.buildDrawingCache();
Bitmap b = textView.getDrawingCache().copy(Bitmap.Config.ARGB_8888, false);
textView.destroyDrawingCache();
try{
String path = Environment.getExternalStorageDirectory().toString() + "/picture.png";
OutputStream outputStream = new FileOutputStream(new File(path));
b.compress(Bitmap.CompressFormat.PNG, 0, outputStream);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
代码示例来源:origin: pchauhan/EdittextWithTag
Bitmap cacheBmp = textView.getDrawingCache();
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
textView.destroyDrawingCache(); // destory drawable
BitmapDrawable bmpDrawable = new BitmapDrawable(viewBmp);
int width = bmpDrawable.getIntrinsicWidth() ;
代码示例来源:origin: AmaldevTA/ChipLayout
private SpannableStringBuilder textToChip(String val, boolean trim){
SpannableStringBuilder ssb = new SpannableStringBuilder(val);
try{
TextView textView = createAutoCompleteTextView(context);
if (trim){
textView.setText(val.substring(0, ChipLayout.MAX_CHARACTER_COUNT)+"..");
}else {
textView.setText(val);
}
int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
textView.measure(spec, spec);
textView.layout(0, 0, textView.getMeasuredWidth(),textView.getMeasuredHeight());
Bitmap b = Bitmap.createBitmap(textView.getWidth(),textView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(b);
canvas.translate(-textView.getScrollX(), -textView.getScrollY());
textView.draw(canvas);
textView.setDrawingCacheEnabled(true);
Bitmap cacheBmp = textView.getDrawingCache();
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
textView.destroyDrawingCache();
BitmapDrawable bmpDrawable = new BitmapDrawable(context.getResources(), viewBmp);
bmpDrawable.setBounds(0, 0, bmpDrawable.getIntrinsicWidth(), bmpDrawable.getIntrinsicHeight());
ssb.setSpan(new ImageSpan(bmpDrawable), 0, val.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}catch (Exception e){}
return ssb;
}
代码示例来源:origin: stackoverflow.com
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888,
true);
textView.destroyDrawingCache(); // destory drawable
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView) lf.inflate(R.layout.chips_edittext, null);
textView.setText(c); // set text
int image = ((ChipsAdapter) getAdapter()).getImage(c);
textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, image, 0);
// capture bitmapt of genreated textview
int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
textView.measure(spec, spec);
textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(b);
canvas.translate(-textView.getScrollX(), -textView.getScrollY());
textView.draw(canvas);
textView.setDrawingCacheEnabled(true);
Bitmap cacheBmp = textView.getDrawingCache();
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
textView.destroyDrawingCache(); // destory drawable
// create bitmap drawable for imagespan
BitmapDrawable bmpDrawable = new BitmapDrawable(viewBmp);
bmpDrawable.setBounds(0, 0,bmpDrawable.getIntrinsicWidth(),bmpDrawable.getIntrinsicHeight());
// create and set imagespan
ssb.setSpan(new ImageSpan(bmpDrawable),x ,x + c.length() , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
内容来源于网络,如有侵权,请联系作者删除!