【发布时间】:2014-07-03 21:07:52
【问题描述】:
我将我的布局保存到一个位图中,其中包含一个 ImageView 和一个 EditText。
我正在使用此代码:
public void saveToImage(RelativeLayout content){
Bitmap bitmap = Bitmap.createBitmap(content.getWidth(), content.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
content.layout(0, 0, content.getLayoutParams().width, content.getLayoutParams().height);
content.draw(c);
try{
File file,f = null;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
file =new File(android.os.Environment.getExternalStorageDirectory(),"TTImages_cache");
if(!file.exists())
{
file.mkdirs();
}
f = new File(file.getAbsolutePath()+file.separator+ "filename"+".png");
}
FileOutputStream ostream = new FileOutputStream(f);
bitmap.compress(CompressFormat.PNG, 10, ostream);
ostream.close();
}
catch (Exception e){
e.printStackTrace();
}
}
但是我保存的图像是这样的:
我想在保存位图时删除edittext中的下划线文本和文本光标。这可能吗?
【问题讨论】:
-
添加这一行:this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);你的 saveToImage() 方法。
-
不幸的是,在没有键盘时也会显示闪烁的光标:(
-
@deimos1988 你的问题解决了吗?!
-
要禁用闪烁的光标,您可以在捕获位图时使用 editText.setCursorVisible(false)