创建一个XML布局内绘制的帆布 [英] Create a drawable canvas inside an XML layout

查看:128
本文介绍了创建一个XML布局内绘制的帆布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Java和Android,所以我不知道这是否是可能的,但我想创建一个动态绘制表面/查看/在我的应用程序的地方。我知道如何用画布绘制取代我的整个XML的布局,但是这不是我想要的。我想preFER这绘制表面是对的(或)顶我的静态布局,我还没有找到如何做到这一点。下面我的意思的说明:

I am new to Java and android, so I don't know if it's possible, but I would like to create a dynamically drawable surface/view/place in my app. I know how to replace my whole XML layout with a drawable canvas, but that's not what I want. I would prefer this drawable surface to be on top of (or in) my static layout and I still haven't found out how to do that. Below an illustration of what I mean:

在此先感谢!

推荐答案

您有不同的选择。你可以把一个自定义的查看并覆盖其的onDraw()方法,其帆布画。另一种选择是使用 SurfaceView (它提供了一个与它的画布,对于较复杂的绘图更有效)。下面是关于href=\"http://developer.android.com/training/custom-views/custom-drawing.html\" rel=\"nofollow\">第一个选项并的第二个选项

You have different options. You can put a custom View and override its onDraw() method to draw with its Canvas. Another option is to use SurfaceView (which provides a Thread for drawing with its Canvas, more efficient for more complex drawing). Here is more details about for the first option and second option.

这篇关于创建一个XML布局内绘制的帆布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆