nambicompany / expandable-fab

A highly customizable 'speed dial' FloatingActionButton implementation.
https://nambicompany.github.io/expandable-fab/
MIT License
199 stars 20 forks source link

XML android:visibility="invisible" not working #46

Closed lividoul closed 1 year ago

lividoul commented 1 year ago

I want to begin my fragment with the fab on invisible visibility mode to then call the method .show() to the fab appear with animation. android:visibility="invisible" is not working on xml

kabumere commented 1 year ago

I've reproduced this and you're correct @lividoul, the ExpandableFab does not honor visibility set through XML.

As a work around, you can get a reference to the ExpandableFab programmatically in your Fragment/Activity and immediately call hide on it, to effectively do the same thing.

For example, in a Fragment:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    val expandableFabLayout = view.findViewById<ExpandableFabLayout>(R.id.expandable_fab_layout)

    expandableFabLayout.getCurrentConfiguration().efab?.hide()
}
lividoul commented 1 year ago

I've reproduced this and you're correct @lividoul, the ExpandableFab does not honor visibility set through XML.

As a work around, you can get a reference to the ExpandableFab programmatically in your Fragment/Activity and immediately call hide on it, to effectively do the same thing.

For example, in a Fragment:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    val expandableFabLayout = view.findViewById<ExpandableFabLayout>(R.id.expandable_fab_layout)

    expandableFabLayout.getCurrentConfiguration().efab?.hide()
}

Doing that show up animation does not perform when I call efab.show() later

kabumere commented 1 year ago

@lividoul,

Which animation on the ExpandableFab (not the FabOptions, correct?) are you expecting to play when you unhide it?

lividoul commented 1 year ago

@kabumere,

The default show up animation of the fab. When you call hide() immediately the animation doesn't perform on the first time you call show(). But if after the first show() you call hide() for a second time and then show() again, the animation will perform. I think this happens on the default fab as well. That's why you set visibility="invisible" on XML.

kabumere commented 1 year ago

@lividoul the ExpandableFab itself does not have a default animation when it's first shown, it's just present in the UI. If you hide the ExpandableFab, then show it later after some condition is met, the ExpandableFab will simply appear in its correct position. Then upon pressing the ExpandableFab, the FabOptions and optional Overlay will animate appropriately.

Please show a gif of what you're expecting if I'm misunderstanding you.

MickeCast commented 1 year ago

@kabumere The same happens with android:visibility="gone"

kabumere commented 1 year ago

@MickeCast,

Please show a gif of what animations you're expecting to play after unhiding the ExpandableFab.

kabumere commented 1 year ago

Closing due to inactivity. If anyone else experiences this issue, please be ready to show/explain the exact behavior you're expecting from the widget.