1

so i am using a <android.support.v7.widget.Toolbar> which is located at the bottom of my app. What i want to do is to hide it when i am scrolling on my listView which i am doing like this:

lv.setOnScrollListener(new AbsListView.OnScrollListener() {
    int mLastFirstVisibleItem = 0;

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {   }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        if (view.getId() == lv.getId()) {
            final int currentFirstVisibleItem = lv.getFirstVisiblePosition();

            if (currentFirstVisibleItem > mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().hide();
                toolbarBottom.setVisibility(View.GONE);
            } else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
                // getSherlockActivity().gvetSupportActionBar().show();
                toolbarBottom.setVisibility(View.VISIBLE);

            }

            mLastFirstVisibleItem = FIRST_LIST_ITEM;
        }
    }
});

the thing is it hides and shows properly but it just happens in a second..means its there and then its gone agaon..no animation..so how can i do an animation that hides it while i scrol down for example if i scrol down 10px the toolbar should also scrol down or disapper for the same amount.. just like google+ or facebook toolbar is doing it.

what i will try to do now: get the amount of scroll from the list and just move the position of my toolbar down and then disable it when its out of the screen..not sure if this is possible though..

the other thing is i infalted a menu in it but the icons only appear on the right side of the bar, why is that and how to fix it?

toolbarBottom.inflateMenu (R.menu.user_interaction);

and the xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >
    <item android:title="Edit"
        android:id="@+id/post"
        android:icon="@drawable/ic_action_pinboard_white"
        app:showAsAction="always|withText"

        />
    <item android:id="@+id/menu_share"
        android:icon="@drawable/ic_action_recent_white"
        app:showAsAction="always|withText"
        android:title="Undo" />
    <item android:id="@+id/test"
        android:icon="@drawable/ic_action_groups_white"
        app:showAsAction="always|withText"
        android:title="Redo" />

</menu>

thx in advance

1 Answer 1

1

how can i do an animation that hides it while i scrol down for example if i scrol down 10px the toolbar should also scrol down or disapper for the same amount.. just like google+ or facebook toolbar is doing it

1st Question: I can see you request many operations on the toolbar, I've got this git that was very usefull for me. I really recommend you to watch it. Has the animation while scrolling + the hiding toolbar.

the other thing is i infalted a menu in it but the icons only appear on the right side of the bar, why is that and how to fix it?

2nd Question: The toolbar items are always inflated at the end of the toolbar. The navigation items are always on the left, it is how google wants to set the toolbar. It can't be set as start like ActionBar.

5
  • so i cant make something like weight or any attribute to get 3 equal buttons accros the whole toolbar? This would really suck :O i wonder how the facebook toolbar on the bottom is done :S thx for the git..ill check it out
    – zooky
    Mar 2, 2015 at 14:17
  • 1
    I see you want a quick return UI, that isn't a toolbar. Take a look at stackoverflow.com/questions/23462698/… post exacly what you searching for.
    – MarcS
    Mar 2, 2015 at 15:00
  • yea i exactly need something like this..but it is set up completly different then my app...il try to figure out if i can combine this.i jsut have troubles importing it :S
    – zooky
    Mar 3, 2015 at 9:05
  • It is only a matter of patience and hard work. Please tick this answer if it help you, maybe will help other users aswell, thank you.
    – MarcS
    Mar 3, 2015 at 9:40
  • yea true..android is all about patience and practise since there are so mayn special things and workarounds etc... Yea but for now i cant figure out how quick return is done :D
    – zooky
    Mar 3, 2015 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.