There are two fragments - RuleListFragmetn and RuleFragment. The RuleListFragment fragment uses the RecyclerView element. Toolbar has app flags: layout_scrollFlags = "scroll | enterAlways | snap", while AppBarLayout has app parameter: liftOnScroll = "true". If the list in RuleListFragment has not been scrolled and the transition to the RuleFragment fragment has been completed, then the Toolbar is in place. If the list in the RuleListFragment has been scrolled (the Toolbar hid at the top), then when you go to the RuleFragment Toolbar fragment, it disappears. The picture below explains. Maybe in the fragment you need to reset the position of the Toolbar? But how to do that?
Your supposition is correct. As the appBarLayout lives in the activity, the toolbar stays hidden when you change fragments.
The solution is to call appBarLayout.setExpanded(true) in the new fragment. You can do it inside onStart, for example.
More information here: AppBarLayout.setExpanded(boolean expanded).
Related
I assume that I have activity A, activity B, and activity C. in activity A there is a listview that displays the name of activity B and C. how do I display the tick icon on the listview in activity A when I finish opening activity B or activity C like the example image below.
example
Add an ImageView to the right side of your ListView item layout and set it to be visible just after calling startActivity(). Or, if this is making the checkmarks visible too soon, you can use startActivityForResult(), which will allow you to set the ImageView's visibility only upon returning to Activity A. If your ListView isn't using custom item layouts, you'll need to learn how to do that.
I've a BottomSheetDialogFragment inside a RecyclerView, when is clicked a button BottomSheet is showing. BottomSheetDialog expanding when scrolling down and collapsing when scroll finished on top normally.
But when I place the RecyclerView inside a fragment and lay the fragment to BottomSheetDialog; BottomSheet behaviours not working on the fragment, only works RecyclerView scrolling. On the other hand the behaviours work other places on BottomSheet. How to enable the behaviours as in the first?
You should check that your container layout has app:layout_behavior="#string/bottom_sheet_behavior"> and check that any listener/event you define extra, otherwise BottomSheetDialog normally behaive as you expect.
I'm struggling with Toolbar Button and ViewPager with TabLayout inside my app. I have multiple Toolbar Buttons, that I want to change dynamically (Add or remove icon/button on Toolbar, and set different onClickListener for each Fragment) inside Fragment loaded inside TabLayout. The main problem here is that ViewPager load 2 fragments in a row in order to provide the scroll animation, but there is no method in order to know if the fragment is really displayed or not... (Except setUserVisibleHint, but this method is deprecated, and doesn't seems to be really reliable), so does someone have a solution in order for my app to run great with that behaviour? (Changing dynamically the icon on my Toolbar inside the Fragment)
Thanks!
Try implementing the logic inside the onResume of your Fragment. onResume basically means that this fragment is visible for the user. This should solve your problem. Hope it helps :)
I'm trying to build a view that will have standard tabs on the bottom and action bar tabs in the upper part of the screen.
I've tried using FragmentTabHost together with TabLayout but with no success since they both call getSupportFragmentManager() so one cancels another.
I've also thought about using deprecated TabLayoutActivity but I'm using AppCompat theme so all my activities have to inherit AppCompatActivity.
Is there a way for bottom tab to start activities and upper one fragments, or at least both starting fragments that work?
You can have 2 framelayouts (bottom,middle).
On bottom framelayout you will have a fragment with buttons as tabs, when you click on each button you will send back to activity which button clicked.
On middle framelayout you can have a TabLayout fragment and if you prefer also 1 fragment for each tab in the tablayout.
One of the solutions is to use getChildFragmentManager() available in the support library to have a Fragment inside another Fragment.
The outer one with FragmentTabHost can be controlled by main fragment manager getFragmentManager() and inner one with TabLayout by child fragment manger getChildFragmentManager().
Here's an example with nested fragments.
Still looking for a viable solution with Activity and a Fragment.
I have a TabHost with a ListView inside a tab. When the activity starts, I can't scroll the list view until I have clicked off the tab that the activity starts on, and then re-select the tab with the list view inside it.
Note, I can get the list view to focus by calling:
tabHost.getTabContentView().requestFocus(); but unfortunately, I still can't scroll until I have reselected the tab...
Have any remedies?
Thanks!
Fixed - I ditched the tabs in order to simplify the layout.