向上滑动面板布局侦听器实现。二级布局可见性问题

Sliding Up Panel Layout Listener implementation. Secondary layout visibility issues

我正在使用 umano https://github.com/umano/AndroidSlidingUpPanel 的向上滑动面板。我面临一个小而愚蠢的问题,但我无法解决它。滑动面板的二级布局有一个文本视图。当我通过向上拖动展开它时,我希望 textView 减慢淡入淡出和消失(如在 SoundCloud 音乐应用程序中)。当我将它向下拖动时,textView 应该再次可见。如何解决?我尝试了很多,但都失败了。[![enter image description here][1]][1]

向上滑动面板标记为红色。

MainActivity.java

 slidingUpPanelLayout = 
(SlidingUpPanelLayout)findViewById(R.id.sliding_layout);


    slidingUpPanelLayout.addPanelSlideListener(new 
SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {

            SongNameSlide.setVisibility(panel.INVISIBLE);
            ArtistNameSlide.setVisibility(panel.INVISIBLE);
            buttonabc.setVisibility(panel.INVISIBLE);

        }

        @Override
        public void onPanelStateChanged(View panel, 
SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
            if(newState.equals(SlidingUpPanelLayout.PanelState.EXPANDED)&& 
previousState.equals(SlidingUpPanelLayout.PanelState.COLLAPSED)){
                SongNameSlide.setVisibility(panel.GONE);
                ArtistNameSlide.setVisibility(panel.GONE);
                buttonabc.setVisibility(panel.GONE);
                slidingUpPanelLayout.setDragView(panel);


            }

        else {

                SongNameSlide.setVisibility(panel.VISIBLE);
                ArtistNameSlide.setVisibility(panel.VISIBLE);
                buttonabc.setVisibility(panel.VISIBLE);
            }
        }
    });

    slidingUpPanelLayout.setFadeOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

 slidingUpPanelLayout.setPanelState (SlidingUpPanelLayout.PanelState.COLLAPSED);
        }
    });

向滑动面板添加一个PanelSlideListener,当用户移动面板时,函数onPanelSlide()将调用面板布局和偏移值。您可以将其添加为:

slidingUpPanelLayout.addPanelSlideListener(
    new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            SongNameSlide.setAlpha(slideOffset);
            ArtistNameSlide.setAlpha(slideOffset);
            buttonabc.setAlpha(slideOffset);
        }
    }
);

现在,您将获得范围从 0 到 1 的偏移量,表示面板打开了多少。使用此偏移值并将其设置为要隐藏的 UI 个元素的 alpha

因为我不知道它会完全打开哪些值,如果它与要求相反,请按这种方式使用 -> SongNameSlide.setAlpha(1 - slideOffset);