ViewPager with ImageViews having pinch-zoom and gestures capabilities - view reuse issue - java

I have a ViewPager with custom ImageView-based class as ViewPager childrens. In my ImageView I have implemnted gesture handling - pinch and 2-finger zoom and image move. Now my problem is that ViewPager reuses view and there is no mechanism for saving particular view state of child views. In my case it results in following - user zooms and/or moves image on particular ImageView, then ViewAdapter reuses view for current view and the image gets display with default scale/position. I wonder how to save the view state so that after view reuse I can load the last state of view to have the correct zoom/move state.
Does anybody have some hints?

Maybe you should use setTag and save the state of the modified child view. If getTag is not null, you can restore the state of the child.

Related

Android animation in a recycler view to change bounds?

I have a recycler view and the rows in each recycler view can have varying size depending on information inside them which is dynamically filled into it.
Now when I scroll the recycler view the layout gets inflated and there is a sudden jerk in the screen. So i want to animate this part where i can just expand the lower bound of the row or any other method suitable.
How do i animate just the lower bound?? please help..
i have used this code
int height = holder.customLayout.getHeight();
holder.customLayout.animate().translationY(height).setDuration(1000);
but it messes up with entire view

Scrollable Views Interacting with other child views like Google street View

I intend achieving a layout similar to what is shown.
I have tried achieving similar behavior with Bottom sheet, percentFrameLayout, ScrollView and Coordinated layout on different occasions, but I've not being able to achieve something similar to the view that (possibly a fragment) that is scroll from the bottom of the screen and interact with other child views on the screen like the tab and the refresh button.
Any guideline and directions on how i can do this ?
You can use a RecyclerView for the cards and leave your toolbar and main content on a FrameLayout at the same level as the map. And of course a coordinator layout and proper behaviors on each element.
By doing this your recycler view will be able to interact with the toolbar and still be independent from the map.
In other words, you can reduce your problem to a single recyclerview scroll with a toolbar by making a space on the beginning of the vertical recyclerView.

how to show selection of the lst item in recycler view in android?

I have implemented the recycler view in navigation drawer in android.This is working fine.I am able to switch between item by clicking on recycler view item.
but i am not able to change the background color for the selected item.please suggest me how to imeplement it.I have tried this so far.
1.Background Selector in RecyclerView Item
Tried to make recycler view clickable,focusable but didn't work
2.http://innodroid.com/blog/post/tracking-selected-item-in-recyclerview
implemented but didn't understand where to write the code for changing background
Please help me out.
What you really need to understand with RecyclerView is that it's not the same control as a Listview with a funky adapter.
RecyclerView does not exhibit many of the ListView's functionalities and whilst it's understandable to compare it to a ListView or a GridView (or event a StaggeredGridView), it shouldn't be confused with them.
With RecyclerView, the responsibilities of handling the "background change" selector relies on the underlying control that the RecyclerView is holding. It's also the same with onClick and many other perks you get for free in a ListView.
Why it is better (or worse) to use a RecyclerView to a ListView is a different matter that I won't go into but to fix your problem, in order to set a background selector on your RecyclerView, add this to the layout that you're inflating in your ViewHolder (i.e. the actual layout that's being used inside the RecyclerView, similar to your "list row item" that you would inflate inside an ArrayAdapter if it were a ListView):
android:clickable="true"
android:background="?android:selectableItemBackground"
Which should set the background appropriately.
Recycler view are recommend when you have very large items & wants to have a custom UI. If you want to display only few items the would recommend to use List View.

Combine Vertical scoll view of parent layout and contents of view pager

I have a 'page' that has a number of components on it, and who's content is longer than the height of the device. one of the component is view pager. Content of view pager is also very large. How can i combine vertical scroll view of parent layout and view pager layout.My laytout is as follows:
few components
view pager-(large content in another layout)
few more component
i want to combine scroll view of view pager and parent layout
It should just work. See here -> ViewPager inside a ScrollView does not scroll correclty
You structure should be like this:
ScrollView
-ViewPager
--ScrollView
Then just apply the suggestions made in the linked post above.
Also make sure the ViewPager has a fixed height! Otherwise the ScrollView inside the ViewPager won't work without writing a custom ScrollView or ViewPager.

info on Drag Entered

When I drag my View, I want to be able to see what view I am dragging into upon drag entered.
I know I can get the View that I am dragging by using
View draggedView = (View) event.getLocalState();
Is there a way to get the View of the drag entered object?
There was no easy way of doing it.
i was able to get the view by going through the views in my layout in a for loop and finding the view by checking equality.

Categories