Bottombar: getBarSize(new OnSizeDeterminedListener()) does not update (attachShy)

Created on 30 Mar 2016  路  20Comments  路  Source: roughike/BottomBar

This only give me one number, when my activity is first launched:

bottomBar.getBarSize(new OnSizeDeterminedListener() {
@Override
public void onSizeReady(int size) {
Log.e("height", String.valueOf(size));
float translationY = Math.min(0, floatingActionButton.getTranslationY() - size);
floatingActionButton.setTranslationY(translationY);
}
});

Most helpful comment

@roughike Then I have to adjust proper translation for FAB in the behavior.

All 20 comments

That one number is height on phones and width on tablets.

@roughike Oh sorry, I ment that when i scroll and the bottombar hides, I need a updated number in order to reposition the fab.

@NikolaDespotoski , is there a way for the FAB automatically update it's position when the BottomBar hides on scroll?

@roughike I think yes. Give me some time.

@NikolaDespotoski
Take as long as you want, there's no rush.

Thanks @NikolaDespotoski @roughike

@alvarlagerlof @roughike I made some progress. It works fine with BottomBar but there is animation glitch when Snackbar goes down. I have to avoid/override default FAB behavior for Snackbar and apply totally new logic for handling translation of the fab for snackbar and bottombar. In the end it should work out of the box just with adding the behavior to the fab as well.

@NikolaDespotoski I'm okay with whatever, as long as it works :smile:

@alvarlagerlof @roughike I failed. Because bottombar replaces user content view which breaks FAB behavior. For a behavior to works the target view must be direct child of coordinator layout.

If FAB was direct child this is how my behavior works:
(Snackbar)
(Scroll)

@roughike If you have any idea that will not break current BB implementation here is the code for he behavior

@NikolaDespotoski Where does BottomTabLayout come from, it isn't recognized by Android studio. Sorry for late answer, is was on a lan.

@alvaragerlof It is from my library. BottomTabLayout should be BottomBar in this library, just change change the name.

@NikolaDespotoski Ah, of course, thanks, trying out tomorrow

@NikolaDespotoski mNavBarSize = Util.getNavigationBarHeight(parent.getContext()); Does not find "Util", is it from the bottombar libary or somewhere else? The import list only contains "Util" from other libarys.

The method can be found in the Util class in the linked repo. However, the fab now is displayed outside the screen at the top and when scrolling down it moves inside the screen from above, but stays halfway behind the statusbar.

@Nolanus this is because the BottomBar tries to replace user content view within its own layout, meaning that FAB is no longer direct descendant of the CoordinatorLayout. This is my first suspicion.
Second suspicion is that my FAB behavior implementation I linked above, is incorrectly offsetting the FAB. Because I take the bottom navigation view height as value to which FAB to be translated, and the height includes entire screen (this is because it wraps user content).

@NikolaDespotoski
Actually when using attachShy(), the FAB and all other Views still stay as direct child of the CoordinatorLayout, except for the View that's specified as the second argument for the method.

@roughike Then I have to adjust proper translation for FAB in the behavior.

@NikolaDespotoski If you can give me a value that is updating every time the snackbar is collapsing or expanding i would be happy, please

Is there any Update on this, the fab still goes below the BottomBar.
If I get LayoutParams and set the BottomMargin manually then the Same Margin is used as the SnackBar Margin and everything looks ugly.

Now since adding the BottomBar to your layout isn't so magical anymore, in the newest version you can just call bottombar.getHeight().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MansoorJafari picture MansoorJafari  路  5Comments

BlaineOmega picture BlaineOmega  路  7Comments

rodrigobressan picture rodrigobressan  路  4Comments

mag2007 picture mag2007  路  8Comments

giautm picture giautm  路  4Comments