I have a layout like this :
I have activity, inside of activity is a fragment and a box, inside of the fragment is a recyclerview (ex. list of song title and image)
Activity -> Fragment -> RecyclerViewAdapter
I'm using this animation, it is working well but the problem is the
animation moves only inside the fragment area. (based on the pic I want it to animate an item from recyclerview going to the box)
holder.rl_main_layout.animate().x(xValue).y(yValue);
so can anyone suggest an Idea to do what I want?
Fly item from recycler view to cart icon on toolbar
Please check this link , this will guide you how you can accomplish your problem
Check this link
Related
I would like to click on an item of a listview to show another listview of other items, what can I do?
in my application I have a main Activity, where I have inserted a bottom view navigation, when you click on an item in the bottom view menu, the corresponding fragment appears in the main activity.
my listview is in the first fragment, and in the same fragment the next screen must appear, after the click in the listview.
do I have to replace the fragment of the listview with another one or can I replace only the listview? how?
Thanks for the attention
Instead of those options (replacing the fragment / list view), you could use the onItemSelected method to repopulate the list view object with the new list. Since you already know how to do this, it would seem the simplest option. A simple switch statement would suffice.
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 am trying to create a main page in my android app in which there are multiple things a user can select to do. For this page, I am thinking of using a RecyclerView with a LinearLayoutManager. For each of the views in the RecyclerView (none of which are as big as the screen), I want a user to be able to swipe into a Fragment (which is as big as the screen).
I have already tried using multiple ViewPagers to solve this problem. When keeping the ViewPager as big as the screen (the default), the Fragment would be the correct size, except the view in the RecyclerView would be as big as the screen (I want it to only wrap_content). When shrinking the size of the ViewPager, the Fragment would not be as big as the screen, but the View in the RecyclerView would be the correct size.
I have heard that one can listen for a user's swipe on a view, except:
- I don't know if that is what I should do in my case, and
- I don't know how to do it for my situation
If listening for a user's swipe is the correct way to go, please give some direction and/or code on how to complete what I want to do. If it is not the way to go, please provide an alternate way.
Thanks in advance!
Update: Here is a picture describing what I mean:
// define your fragment with recycle view
class FragmentA extends Fragment {
// with recycler view
// in click on recycler item method as i posted
// 1) do check if pager fragment exist in pager adapter
// 2) if not create one
// 3) and move to it using pager method
}
// define second without
class FragmentB extends Fragment {
// without
}
// create pager
ViewPager vp = new ViewPager(Context);
// create list with fragments for pager adapter
// when you will swipe you will move from A to B
List<Fragment> // add FragmentA + FragmentB
// https://developer.android.com/reference/android/support/v4/view/PagerAdapter.html
// create pager adapter - implement own or user FragmentPagerAdapter
PagerAdapter ... = new MyPagerAdapter(List<Fragment>);
// set view pager with adapter
viewPager.setAdapter(PagerAdapter);
// add view pager to activity view - or some content view
I already tried this on my own; the viewpager would not allow for the
correct sizes. Either the full-screen fragment size was shrunk down to
the size of the View in the recyclerview, or the view in the
recyclerview was full-screen. – Flare Cat
its working:
Oh wait, read the code wrong. But still, I need to base FragmentB off
of what was swiped in FragmentA – Flare Cat
solution:
when you click on recycler item dynamic create new fragmentB and call move to fragmentB on pager (before create new one do a check if fragment not exist already!)
or if you don't use any click on item method but just constant recycler item content create such fragments corresponding to each entry in recycler
or create some sort of map which will map each entry in recycler to to its corresponding fragment content
As I understand it, I would need to create an onClickListener for each
view in the RecyclerView. But, would that onClickListener be called
when a user swipes the corresponding view? – Flare Cat
Actually, this might work with an onTouchListener. I'll have to try it out. – Flare Cat
once again:
it depends what u want to achieve - if recycler is a way of brief for each fragments and you know the content and want to present each entry for recycler item counting from top to bottom then you need add those fragments one by one in same order from left to right
#FlareCat but why using pager here ? not better to open new activity or add fragment with transition on recycler item click ?
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.
I have a listview, clicking on one of the item in listview takes me to some fragment (different item may take to different fragment). Once a new fragment is opened I want to swipe to open the the next item in list instead of going back and clicking on the next item. I am thinking of using ViewPagers but not sure how to open the next item in the list.
You can create an Activity which has a ViewPager and Fragments with desired info as its children. On a list item click, take the position info and pass it to the Activity via Bundle. And inside the Activity after setting the ViewPager, you can show the desired Fragment with ViewPager's setCurrentItem(int item) function.