我在我的应用程序中使用了ScrollView。它包含一个LinearLayout作为子项,其他一些视图喜欢 TextViews,Buttons等...作为子视图。现在我想将scrollview的内容发布为FaceBook wall上的图像。我找不到合适的帖子。
**My question is how to post ScrollView/Layout content on facebook wall?...**
先谢谢
答案 0 :(得分:1)
使用此功能将您的视图转换为位图图像
public Bitmap getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(480, 640,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
return returnedBitmap;
}
然后在Facebook墙上发布位图图像
希望能帮到你..答案 1 :(得分:0)
我将上面的代码更改为
public Bitmap getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getMeasuredWidth(),
view.getMeasuredHeight() , Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
return returnedBitmap;
}
它工作正常,并获得所有内容的位图。