开发者

drawing layout through canvas

I have a layout like :

<ll vertical>
<ll horizental>
<textview></textview>
<textview></textview>
</ll>
<ll horizental>
<textview></textview>
<textview></textview>
</ll>
</ll>

The problem is i need to display this as part of my whole screen.

i am doing

    mCustomDrawableView = new CustomDrawableView((Context)this, R.drawable.mychart);
    setCont开发者_开发百科entView(mCustomDrawableView);

and on ondraw of my custom view i am drawing the bitmaps etc.

The problem is how can I make above layout into a ibitmap, so that I can draw it in this custom drawing ?

I need to do this because in the layout, one TextView will have right aligned text which is difficult to do in custom drawing.


You should be able to inflate the layout and build the paramaters/child-text-views you want. Then, create a Canvas from your own Bitmap and call the layout's 'draw' function passing in your own canvas. The layout should then blit all of it's children into your custom bitmap, which, you can then do whatever you want with.

http://developer.android.com/reference/android/view/View.html#draw(android.graphics.Canvas)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜