我已经相对布局命名rel
动态地将一个imageview的它,像这样:试图采取视图的屏幕截图和它的孩子
rel.setBackgroundResource(R.drawable.bg_share_one);
RelativeLayout.LayoutParams p1 = new RelativeLayout.LayoutParams(921, 691);
p1.leftMargin = 30;
p1.topMargin = 30;
ImageView img = new ImageView(this);
img.setLayoutParams(p1);
myBitmap = BitmapFactory.decodeFile(files[0].getAbsolutePath(), option1);
img.setImageBitmap(myBitmap);
rel.addView(img);
saveCompareImage();
然后我把这个方法采取截屏的相对但它添加的imageview没有显示在位图中:
protected void saveCompareImage() {
// TODO Auto-generated method stub
rel.setDrawingCacheEnabled(true);
try {
File file = new File("/sdcard/LC/compare.jpg");
file.createNewFile();
Bitmap bm = rel.getDrawingCache();
FileOutputStream ostream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.JPEG, 80, ostream);
ostream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
会是这样的相对布局应该得到这个或ImageView的我加入吧..我都尝试并没有什么区别..仍然没有ImageView的显示up – erik
我不确定,从来没有尝试过,只是看到了API Doc的一部分。我猜你必须在布局和图像视图中都使用它。 – Ridcully
不行不行 – erik