Android工程图视图,当view.startAnimation

问题描述

我正在使用自定义视图来实现滑动功能

https://github.com/umano/AndroidSlidingUpPanel

我已经修改代码,并尝试为滑动子视图手动设置动画

public void animatePanel() {
    final Animation myAnim = AnimationUtils.loadAnimation(getContext(),R.anim.slideup);
    LinearInterpolator interpolator = new LinearInterpolator ();
    myAnim.setInterpolator(interpolator);
    mSlideableView.startAnimation(myAnim);
}

但是当调用animatePanel时,动画是正确的,但是视图背景 对于动画区域,当进行动画时,期望的是黑色 它应该显示底层视图

我将根视图背景更改为黄色,问题颜色变为黄色 这意味着在动画区域中未绘制任何子视图

结构

Image showing issue

<SlidingLayout> //yellow BG
<ChildView1> //purple BG
<ChildView2> //blue BG
</SlidingLayout>

紫色childview1(充当非滑动根) 黄色的滑动布局背景

这里有drawchild的库实现

    @Override
    protected boolean drawChild(Canvas canvas,View child,long drawingTime) {
        boolean result;
//        final int save = canvas.save(Canvas.CLIP_SAVE_FLAG); //original code,not compiling,idk what this is
        final int save = canvas.save();

        if (mSlideableView != null && mSlideableView != child) { // if main view
            // Clip against the slider; no sense drawing what will immediately be covered,// Unless the panel is set to overlay content
            canvas.getClipBounds(mTmpRect);
            if (!mOverlayContent) {
                if (mIsSlidingUp) {
                    mTmpRect.bottom = Math.min(mTmpRect.bottom,mSlideableView.getTop());
                } else {
                    mTmpRect.top = Math.max(mTmpRect.top,mSlideableView.getBottom());
                }
            }
            if (mClipPanel) {
                canvas.clipRect(mTmpRect);
            }

            result = super.drawChild(canvas,child,drawingTime);

            if (mCoveredFadeColor != 0 && mSlideOffset > 0) {
                final int baseAlpha = (mCoveredFadeColor & 0xff000000) >>> 24;
                final int imag = (int) (baseAlpha * mSlideOffset);
                final int color = imag << 24 | (mCoveredFadeColor & 0xffffff);
                mCoveredFadePaint.setColor(color);
                canvas.drawRect(mTmpRect,mCoveredFadePaint);
            }
        } else {
            result = super.drawChild(canvas,drawingTime);
        }

        canvas.restoretoCount(save);

        return result;
    }

我在做什么/图书馆在这里做错了吗?

如何消除黄色背景并在其中显示紫色视图 应该是正常行为的地方。

这里是库视图组的链接

https://github.com/umano/AndroidSlidingUpPanel/blob/master/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)