Android - Make StatusBar transparent on a specific fragment in ViewPager - android

I have a ViewPager with several fragments, his layout includes only the ViewPager with a TabLayout, nothing else.
And one specific fragment (in view pager) which has a coordinator layout with collapsing toolbar (on the right)
What I want to do is to set the StatusBar transparent only on the right fragment. Just imagine I want to move the picture on the right fragment completely top
I've tried several methods like android:fitsSystemWindows="true" , make the ViewPager fullscreen (it wasn't what I expected) or modify application theme. But this is a specific situation that I can't find any solution. Thanks for any ideas.

Related

Jetpack BottomNavigationView How to remove content fade in animation

I'm creating a single activity applicatition. Inside Activity there is a BottomNavigationView
with NavHostFragment. Bottom navigation view comprise of multiple menu items.
For easy to explain lets say there are three fragments "FragmentOne", "FragmentTwo", "FragmentThree"
each fragment have a different Toolbar. As a example "FragmentOne" is haveing a Toolbar with CollapingToolbarLayout, and "FragmentTwo" has a Normal Toolbar Design and "FragmentThree" has a toolbar with Image.
I have included different design Toolbars in each fragment and the BottomNavigationView is inside Activity.
Where select each bottom navigation menu, fragments are navigating correctly but content is showing fade in animation/transition.
I have set the app theme as Theme.AppCompat.Light.NoActionBar So now since Toolbar is also inside the fragment content area Toolbar also showing fade in transition.I'm okay with content transition but Toolbar should stay Solid.
Kindly help to me to solve this and feel free to request more information.

ViewPager with TabLayout inside a NavHostFragment in an AppBarLayout

Ok, please bear with me: I'm using the android navigation component for a new app I'm building. I need the ActionBar and the BottomNavigationView to hide on scroll, which I've done successfully by using an AppBarLayout inside a CoordinatorLayout.
In my app's theme I'm using "windowActionBarOverlay = true", since I need the ActionBar to be transparent in some of my fragments. In one of my Fragments, I have a ViewPager with a TabLayout, and a solid ActionBar. To overcome the issue that windowActionBarOverlay creates, I've added some paddingTop to my whole fragment.
However, this creates a problem when the user scrolls, since the ActionBar gets hidden away, and there is an empty space where the padding is.
I can use two solutions, although I don't know how to implement each of them:
Make the ViewPager scroll with the ActionBar. How can I do that, in my situation, where the ViewPager is inside a Fragment in a NavHostFragment?
Make the ActionBar not hide itself when the user scrolls. Is there a way to disable this programatically for particular fragments?
If anyone knows how to implement one of the two solutions, please let me know.

Is it possible to implement a TabLayout with activities

I have a Tablayout kind of a bottom navigation, and I want that when the user clicks in a cardview that I have it sends him to another Tablayout but when that happens the bottom navigation does not appear anymore. That is only possible with activities right?
A TabLayout is just a view like any other. It can be inflated as a part of another view, or as the content view for a Fragment or an Activity. So, you're not restricted to using just an Activity with a TabLayout.
Now, if you want it so that when you click on a CardView you're taking to another screen without a TabLayout, you have a couple of options:
Open a new activity
Since this second Activity is going to have a different content view, it's not going to have the TabLayout from the first activity.
Hide the TabLayout and change the content surrounding the CardView
Since we're sticking with the first Activity, we're going to need to make all of our content changes to the views in the Activity. This means setting the visibility on the TabLayout to View.GONE and potentially lots of changes to the rest of the views depending upon what your layout contains.
I noticed that you didn't mention a ViewPager at all. Typically, this is what will be used with a TabLayout to swap between Fragments when you click on each tab. You could have all of your tabs' content in separate Fragments and then when you click on a CardView, just swap that tab's Fragment out for a different one and hide the TabLayout.
So, to answer your question, it is easier to just open a new activity, but it is possible to not use a second activity if you want to put in the work to modify your first one in runtime.

Fragment in CoordinatorLayout does not scroll

This is a followup of this question where you can find all source code: Android does not show tabs
Originally I had no fragment, no tabs, just single activity that used NestedScrollView to hold its content and it worked like a charm - appbar was shortened when I scrolled and I was able to scroll the content.
Now I try to introduce tabs and I moved the content into new Fragment. I used ViewPager with layout_behavior attribute in the activity and LinearLayout in a fragment layout. I think that this is similar to CoordinatorExamples. But the content does not scroll at all and appbar is static, it does not changes when I try to scroll.
Where is the problem? The ViewPager must be OK as it works in the sample.

Semitransparent PagerTabStrip with actionbar overlay

I'm using a actionbar with Window.FEATURE_ACTION_BAR_OVERLAY and some transparency. Additionally I'm using a ViewPager with a PagerTabStrip. The problem is the PagerTabStrip is now displayed underneath the actionbar.
Applying a margin to the PagerTabStrip doesn't work at all and applying a margin to the whole ViewPager prevents the content (A ScrollView inside a Fragment) to scroll underneath the actionbar and the PagerTabStrip, which should be semitransparent too.
So currently I'm stucked with
which isn't ideal at all :D
Anyone got an idea to implement this behaviour?
Edit: so the problem consists of 2 parts. Making the content scroll underneath the PagerTabStrip and moving the PagerTitleStrip.
Add a view above the pager tab strip with a height of
?android:attr/actionBarSize
It will take the height of the action bar and "push" the content down.

Categories

Resources