在画廊视图顶部自定义绘制(和它的子视图) [英] Custom drawing on top of Gallery view (and it's child views)

查看:256
本文介绍了在画廊视图顶部自定义绘制(和它的子视图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在画廊的上面画自定义用户界面(在这种情况下路径)。我已经扩展底座画廊类,并覆盖Draw方法是这样的:

I'm trying to draw custom UI (a path in this case) on top of a Gallery. I've extended the base Gallery class and overwritten the draw method like this:

public class MyGallery extends Gallery {
...
@Override 
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawPath(mPath, mPaint);
}

我觉得把我的画路径后 super.onDraw 将确保该路径被画在画廊之上,这是孩子的意见,而是孩子的意见是分层的,我的道路上。
有谁知道如何正确地得出这样的?
(我知道我可以包括的RelativeLayout和层次进一步视图中绘制的画廊这样的顶我的道路,但我宁愿这一切保持在一个类)

I thought that putting my path drawing after super.onDraw would make sure that the path was drawn on top of the gallery AND it's child views, but instead the child views are layered on top of my path. Does anyone know how to draw this properly? (I know I could include a RelativeLayout and layer a further view to draw my path on top of the Gallery that way, but I'd rather keep it all in one class)

推荐答案

我发现这个要求后直,所以决定的情况下,反正有人张贴了同样的问题。为了笼络子视图在一个画廊,覆盖 dispatchDraw 而不是的onDraw

I found this straight after asking, so decided to post anyway in case someone has the same issue. To draw over child views in a Gallery, overwrite dispatchDraw instead of onDraw

@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    canvas.drawPath(mPath,mPaint);
}

这篇关于在画廊视图顶部自定义绘制(和它的子视图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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