Audo
Audo

Reputation: 13

How to display a fragments view over tabLayout

I have a tabLayout with some fragments. I want to display one tabs view in sort of a fullscreen as an image (apart from the native phone statusbar) that covers the tabLayout. I want the image to completely overlap the tabLayout so the only way to get out of that view is to hit the phones backbutton. The attached images should help you get a better idea of what I am looking for.

MainTab:
enter image description here

Incorrect tab:
enter image description here Correct tab:
enter image description here The code I use to create the tabLayout:

https://gist.github.com/AndreiD/960c171c5c5137e95dde#file-android_view_pager

I tried a lot of xml editing but nothing works so far, the content is always displayed under the tabLayout (as shown in the incorrectTab). Does it have something to do with the usage of coordinatorlayout instead of a relative layout?

Upvotes: 1

Views: 440

Answers (2)

user4875457
user4875457

Reputation:

You could try retrieving the tab layout from the fragment which you intend to cover the view with. Once doing this, try something along the lines of sliding mTabLayout.setVisibility(View.Gone)

Upvotes: 0

apelsoczi
apelsoczi

Reputation: 1122

Something along these lines may help out,

private ViewPager.OnPageChangeListener listener = new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (position == X) {
                getActivity().getActionBar().hide();
            }
            else {
                getActivity.getActionBar().show();
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    };

Upvotes: 2

Related Questions