让SlidingDrawer内容的部分总是可见的? [英] Make SlidingDrawer's content's part always visible?

查看:136
本文介绍了让SlidingDrawer内容的部分总是可见的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了android:bottomOffset使抽屉从底部伸出100dip。这工作正常,但我的内容是不可见的。当我触碰抽屉它才可见。我怎样才能使它总是可见的(在100dip显示的内容)?

I'm using android:bottomOffset to make the drawer stick out 100dip from the bottom. That works fine, but my content is not visible. It's only visible when I touch the drawer. How can I make that its always visible (the 100dip show the content)?

我首先想到它是知名度的问题,因为内容的可见性设置为 onFinishInflate GONE() prepareContent( ) closeDrawer() ...复制的SlidingDrawer并删除这些行,并没有解决这个问题。这似乎是一个位置的问题,我目前玩的数字,但仍然没有找到如何使内容出现的地方应该是...不要有更多的时间为这个...任何帮助大大AP preciated。

I first thought it's a visibility issue, because the visibility of the content is set to GONE in onFinishInflate(), prepareContent(), closeDrawer()... copied the SlidingDrawer and removed these lines, didn't solve it. It seems that it is a position issue, currently I'm playing with the numbers but still don't find how to make the content appear where it should be... and don't have more time for this... any help is greatly appreciated.

下面是快速了解问题的图片:

Here's a pic of the problem for fast understanding:

我想,它看起来像在右侧部分,从一开始。

I want that it looks like in the right part, from the beginning.

这个默认的行为看起来也错误给我,我不知道为什么有人会想打只偏移为抓手,使之与内容之间的差距,然后在触摸直接把内容手柄下...

This default behaviour also looks erroneous to me, I don't know why somebody would want to make the offset only for the handle, making a gap between it and the content, and then on touch put the content directly under the handle...

推荐答案

下面是一个有效的解决方案:

Here is a working solution:

创建SlidingDrawer类的完整副本,然后用替换法 dispatchDraw ,所以它看起来是这样的:

Create a full copy of SlidingDrawer class, and then replace the method dispatchDraw so it looks like this:

@Override
protected void dispatchDraw(Canvas canvas) {
    final long drawingTime = getDrawingTime();
    final View handle = mHandle;
    final boolean isVertical = mVertical;

    drawChild(canvas, handle, drawingTime);

    //if (mTracking || mAnimating) {
        final Bitmap cache = mContent.getDrawingCache();
        if (cache != null) {
            if (isVertical) {
                canvas.drawBitmap(cache, 0, handle.getBottom(), null);
            } else {
                canvas.drawBitmap(cache, handle.getRight(), 0, null);                    
            }
        } else {
            canvas.save();
            canvas.translate(isVertical ? 0 : handle.getLeft() - mTopOffset,
                    isVertical ? handle.getTop() - mTopOffset : 0);
            drawChild(canvas, mContent, drawingTime);
            canvas.restore();
        }
    //} else if (mExpanded) {
        //drawChild(canvas, mContent, drawingTime);
    //}
}

我所做的是注释行。正如所看到的mC​​ontent,这是滑动件的内容,只有被绘制时,无论mTracking,mAnimating或mExpanded是真实的,而滑动件是封闭,它是并非如此。也许是开发商没有心目中的内容,而封闭的滑块表现的一部分,所以它没有任何意义绘制内容,而滑盖关闭。

What I did was comment lines. As you see mContent, which is the content of the slider, only gets drawn when either mTracking, mAnimating or mExpanded is true, which is not the case while the slider is "closed". Probably the developers didn't have in mind a slider showing part of the content while "closed", so it didn't make any sense to draw the content while the slider is closed.

这篇关于让SlidingDrawer内容的部分总是可见的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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