taltstidl / AndroidSlidingUpPanel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.
http://umano.me
Apache License 2.0
13 stars 6 forks source link

FAB not showing after calling fab.show() #25

Closed JeffreyCA closed 4 years ago

JeffreyCA commented 8 years ago

So below is what I have for my listeners:

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

sliding_panel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

    @Override
    public void onPanelExpanded(View panel) {
        Log.i(TAG, "onPanelExpanded");
        fab.hide();
    }

    @Override
    public void onPanelSlide(View panel, float slideOffset) {

    }

    @Override
    public void onPanelCollapsed(View panel) {
        Log.i(TAG, "onPanelCollapsed");
        fab.show();
    }

    @Override
    public void onPanelAnchored(View panel) {
        Log.i(TAG, "onPanelAnchored");
    }

    @Override
    public void onPanelHidden(View panel) {
        Log.i(TAG, "onPanelHidden");
    }

    @Override
    public void onPanelHiddenExecuted(View panel, Interpolator interpolator, int duration) {
        Log.i(TAG, "onPanelHiddenExecuted");
    }

    @Override
    public void onPanelShownExecuted(View panel, Interpolator interpolator, int duration) {
        Log.i(TAG, "onPanelShownExecuted");
    }

    @Override
    public void onPanelExpandedStateY(View panel, boolean reached) {
        Log.i(TAG, "onPanelExpandedStateY");
    }

    @Override
    public void onPanelCollapsedStateY(View panel, boolean reached) {
        Log.i(TAG, "onPanelCollapsedStateY");
    }

    @Override
    public void onPanelLayout(View panel, SlidingUpPanelLayout.PanelState state) {
        Log.i(TAG, "onPanelLayout");
    }
});

The FAB is visible upon application launch. When I drag the bottom view up to expand it, the FAB fades (as stated in the XML file sothree:umanoFabMode="fade"), and then is hidden from view after onPanelExpanded is called. I get the Log message as well. Now when I drag the view down to collapse it, the FAB does not show up, but the Log message in the onPanelCollapsed method is triggered. Even though I put fab.show(); in the onPanelCollapsed method, when triggered, the FAB does not appear. No matter how many times I expand and collapse the bottom view, the FAB never appears.

Now this is where it gets interesting. Here is the entry for the FAB in my XML file:

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="16dp"
        android:clickable="true"
        android:src="@drawable/image_area"
        android:tint="@android:color/white" />

If I add android:visibility="gone" to the entry above, when I launch the application the FAB does not appear. When I expand the bottom view it does not appear either. But when I collapse it, the FAB re-appears. This is almost what I want, except that the FAB should be visible upon initial launch. The FAB re-appears and disappears as it should upon collapsing or expanding after that.

Could you please look into this issue? Thank you very much.

JeffreyCA commented 8 years ago

Unlike your demo, my sliding up panel never reaches full height of the screen. I used layout_weight to set the maximum height to a percentage of the screen. Because of this, the button never fully fades away.

JeffreyCA commented 8 years ago

I've narrowed down the bug to the fade mechanism. When sothree:umanoFabMode is set to fade, this bug happens. When set to leave_behind or circular_reveal, the FAB shows up and hides as expected.

JeffreyCA commented 8 years ago

I think it is something with this commit.

taltstidl commented 8 years ago

@JeffreyCA Thanks for reporting this issue, I'll take a look at it as soon as I can!