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

FloatingActionButtonLayout empty until activity restart #20

Open Aztriltus opened 8 years ago

Aztriltus commented 8 years ago

Hi TR4Android

First of all, I would like to thank you for creating this fork of the SlidingUpPanel! Works great for my design!

Currently, I'm facing an annoying issue. Let me give you some background info first. I'm using Android studio 2.0 canary version w/ the instant run feature for my project (android build tool 2.0 for my project). Also, I'm on SDK 23, and I'm using all support libraries at v23.1.1 (including FAB).

My current project is a CoordinatorLayout w/ Collapsing Toolbar w/ Viewpager with 3 horizontal fragment. Your FABLayout is the root view of the 2nd fragment.

Whenever I start my app (after closing it or re-run), the 2nd fragment is always empty. So it'll just show a background color. But you know, with the new android studio 2.0 canary build, I could restart the activity without re-compiling the entire app. Once the activity restarts, FabLayout then shows itself. If I close the app and open it again, it disappears. As a result, it needs the activity to be re-created in order to show itself.

Any idea what is wrong? SlidingUpPanel without your FabLayout and the FAB works fine. Once I add your Fablayout as the root view with the FAB, all things go south.

Just in case you need it, this is my fragment layout: If GitHub displays it incorrectly, here's the pastebin: http://pastebin.com/MpuH5CM7

<com.sothree.slidinguppanel.FloatingActionButtonLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fab="http://schemas.android.com/apk/res-auto" xmlns:sothree="http://schemas.android.com/apk/res-auto" android:id="@+id/fabLayout" android:layout_width="match_parent" android:layout_height="match_parent" sothree:umanoFabMode="leave_behind">

<com.sothree.slidinguppanel.SlidingUpPanelLayout
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoAnchorPoint="0.5"
    sothree:umanoPanelHeight="84dp"
    sothree:umanoShadowHeight="2dp"
    sothree:umanoInitialState="hidden">

    <subsamplingimageview
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="@style/Widget.CardContent">

        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="left|top"
            android:text="Title"
            android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>

    </RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_action"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    android:tint="@android:color/white"
    fab:backgroundTint="@android:color/black"
    fab:elevation="6dp"
    fab:pressedTranslationZ="12dp"/>

</com.sothree.slidinguppanel.FloatingActionButtonLayout>

taltstidl commented 8 years ago

@Aztriltus Thanks for the background info! Have you used the FloatingActionButtonLayout before and did that work? Or was this an issue introduced with the new Android Studio release? Otherwise I can't think of anything particular being wrong with your layout. I've never used API 23 yet. I have also never used it inside a Fragment, so that might be an issue. Can you get it working inside an Activity? I'll investigate this later, but I've got limited time currently. I'll see what I can do. Thanks for reporting it!

Aztriltus commented 8 years ago

@TR4Android

Activity works fine. I've sort of narrowed it down the problems to just fragments.

Guess what, if I change your layout from fragment 2 to fragment 1, it works fine. Since my app starts up with fragment 1 showing, your layout appeared without a problem. When I use the same fragment for fragment 1 and 2 of my viewpager, fragment 1 showed but fragment 2 doesn't.

So I'm guessing it has something to do with viewpager not loading your fragment properly when it is not in view. Weird. My recyclerview fragment works fine at fragment 3 so... Something to do with ViewGroup?

Thanks for your prompt reply! For now I'll just debug as fragment 1 for designing purposes. Worse come to worse, I'll just do something with ViewPager.