My application has the following design paradigm: One activity hosting fragments that display content.
One fragment holds a RecyclerView, and inside that Recyclerview I have CardViews that display content. I am trying to create a fragment transition so when a user clicks on a CardView, it expands/transforms that cardview into the next fragment.
How could I do this?
I have successfully created transitions from one fragment to another but I can't seem to find a transition that does this.
Related
I am trying to implement bottom sheet behavior to fragment.The two points are need to implents
i)calling one fragment to another when button is clicked.
ii)apply bottomsheet behavior to fragment B,So that When I drag down the fragment can hide/dismiss.
Currently I am having two fragment A,B.I call fragment B in Fragment A by a container When button is clicked .
But when I am trying to implent second point I get error.On FrgmentB I am extend only Fragment not Fragmentdialog. The main reason is I cannot able to acess the background UI.
I have the same problem before, what I did is change the fragment to BottomSheetDialogFragment and made some changes.
I want to animate a recyclerview item to outside(sibling) of the recyclerview. I tried many different animation code and libraries but nothing happened. My problem is to animate a row of recyclerview to a linearlayout outside(sibling) of recyclerview.see attached picture.
My Main Layout flow is:
ConstraintLayout
--LinearLayout
----View (empty)
--Recyclerview
I believe you can use Shared element transition built-in from Android (search for more tutorial about this keyword)
It doesn't support the transition from within 1 view. But you can use Fragment to achieve the same result. Your activity will be like this:
ConstraintLayout (Activity)
--FrameLayout (container for the Fragment)
--Recyclerview
The Fragment contains the layout of your item's destination view.
I imagine the flow can be like this:
User taps on an item in RecyclerView in Activity
Replace new fragment to the container with defined data for shared element transition
https://medium.com/#bherbst/fragment-transitions-with-shared-elements-7c7d71d31cbb
I'm trying to add a slidingUpPanel(Sliding up panel) across all activities. This panel consists of a viewpager which in turn consists of two fragments. One of these fragments has a recyclerView (more than 1000 items) and the other fragment has some data that changes dynamically depending on the users' choice. This panel is very similar to that of google play music and soundcloud. Now to display this panel I tested two approaches:
1) I created a base activity and added the sliding up panel to it and then extended rest of the activities to base activity. So this way I have to create only one panel and viewpager.
2) I included the sliding up panel in all activities. But this approach is quite unmanageable as I have create viewpagers for all activities and if data changes in one activity I have to write the code to reflect that change across all activities.
Now the problem with both the methods is that each time I open a new activity, a new instance of the viewpager and fragments is created. So, suppose if I have 1000+ items in the recyclerview fragment, switching activities takes more than 2-3 seconds, because each time new instance of fragment is created and the data is loaded all again. This will definitely result in bad user experience.
Is there any way by which the viewpager and the fragments are created only once(when the app starts) and are destroyed only when user closes the app? And data should not load each time user switches activities. I just want to reduce the activity switching time. Any ideas?
Thank you.
Well, for such ui elements as your sliding panel, which stays the same for many items it is preferable to have a single activity.
So if you have 1 activity, you can have a viewpager inside sliding panel, and that part stays untouched. Next, inside your activity you can have FrameLayout wich can be used to host fragments. Doing this you can achieve single instance of sliding panel and navigation between content with fragments.
Having some heavy data collections makes you wishing minimum recreation of that items.
Two approaches for this are (assuming you're using SlidingUpPanelLayout by sothree)
With bottom navigation view
Easy way to do it is creating a bottom navigation view and keeping it in MainActivity and attaching the sliding up panel layout to the bottom navigation view ( layout_above = bottomnavbar_id ) since bottom navigation stays throughout the app so sliding up panel will also have to stay with it
Without bottom navigation view
Create a frame layout inside MainActivity give attributes width and height as match_parent and create slidinguppanelayout and give attributes gravity="bottom"
make the frame layout stay above that slidinguppanellayout , use that frame_layout to show content your want to show from fragments
that's all
I am currently using a ViewPager with a TabLayout, the ViewPager as of now consists of three separate fragments.
I would like to be able to switch to a fourth fragment using a button on one of the already present fragments.
However, I do not want the fourth fragment to be accessible through the usual ways (aka scrolling) without using the button to reach the fourth fragment. Similarly, I would like scrolling to be disabled when I am currently displaying my fourth fragment.
What would be the best way to do so?
The current hack that I can think of would be to create a hidden fragment within my main layout. I can then display it when the button is pressed while hiding the ViewPager at the same time.
Are there any better ways to do this?
Include your ViewPager in fragment and onClick make replace for the next fragment, and you can return to ViewPager`s fragment onBackPress.
In my tablet application I want to create a fragment that displays information based on a list fragment click, the fragment has different tabs that I want to scroll between with a view pager. But the problem is that you can't do a fragment in a fragment so how can I achieve what I want to do or is it even possible to do what I want?
basically I have a persistant list fragment on he left, choosing an item shows some sort of view that I can scroll between tabs. I am trying to avoid creating a whole separate activity since I do a lot based on this list view click in this activity
If I understand you correctly then the only structure that comes to my mind is to use the ViewPager as the highest level and put the listadapter on the left side of each view, switching between the views by pressing on an item in the listView.
Just create one common xml base file and include the specifics for each view in the xml file for each view. This way you can have a hierachy in the xml file that makes development easier