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.
Related
The structure of the app is one Activity and multiple Fragments(+ 20).
The Activity has a Toolbar with a title and back button that i used in multiple Fragments.
Then there is two more types of Toolbars that i use inside multiple Fragments, one contains an EditText and the other one is an Expandable Toolbar.
An example would be:
Fragment A: Uses Toolbar from Activity. Show that one, hide if another is showing.
Fragment B: Has a Toolbar of it own, now i need to hide the Activity toolbar.
What would be the correct approach to show/ hide the correct toolbar?
Things i tried:
Using onDestinationChangedListener checking the id of the fragment and show/ hide the correct toolbar. The problem here is that it cause the screen to flicker and i have to check for every id.
toolbar.isVisible = destination.id in listOf(id1, id2...)
Hide or show the correct Toolbar from the Fragment. But then i need to set the toolbar on every Fragment.
(requireActivity() as MainActivity).showToolbar(true)
Removing the Activity Toolbar and creating a new one inside every Fragment. But i don't know if the best way and if it is expensive to constantly inflate the Toolbar.
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.
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.
I would like to make a layout that it would be something like this:
A login layout with no toolbar or title bar
A select action layout with toolbar and no tabs
Another layout with toolbar and 3 tabs
and im thinking on how to implement this, how many fragments, activities etc.
I was thinking of having 1 activity full screen and another activity with fragments, toolbar and tab and every time i want a layut with tabs to remove the tabs and in the next screen to add again the tabs.
But after thinking it out it seems like a bad idea.
Should i create a seperate activity with fragments and tabs and navigate around those 3 layouts?
What is the best approach when you want to use tabs and a toolbar but you dont want in all your layouts to have tabs?
You only need 1 Activityand 3 Fragments. In the fragments where you need a toolbar, just use Toolbar view. This is available on Support Library so you will not have problems with older Android versions.
And in the Fragment with the tabs, just use a TabLayout and a ViewPager in order to switch between tabs (each tab is a Fragment).
I have an application with Activity, Fragment inside activity, Toolbar and Navigation Drawer.
I need a Toolbar will hiding when I scroll content of fragment.
Following manual I need to put ToolBar and scrollable content inside same XML file. But my scrollable content placed in Fragment and ToolBar placed in Activity. How to implement collapsing Toolbar?
You need to use CoordinatorLayout
Try to use this guide. There's good explanation