I've added a Map from google play services as a headerview of my listview. However, when trying to pan on the map, the list immediately takes over and starts scrolling up and down. If the user intents to pan the map(e.g. he starts a touch event on the maps surface) it should block the listview from handling the input. How do i achieve this?
note: when starting a touch on the listview, it should still scroll as a normal listview :)
I think you can try to use a static(fixed) header view, so touching your header view wont scroll your listview.
Also, I think putting a Google Map inside a header view is not really a good practice. I think a better practice is to put a MapFragment on top, then put listview below the MapFragment
Related
I am looking for some ideas on how to best achieve this effect. I have two fragments, one containing the map (and all controls) and another fragment that contains my RecyclerView to display the results. In my activity layout I would like to position my map and list fragments exactly how it is shown in this video. The map fragment shall stay aligned with the topmost edge of the list unless the user is actively scrolling the list upwards. The video I recorded should demonstrate what it is I am trying to achieve.
From an explanatory standpoint, I need view and layout ideas. I have already implemented all the necessary callbacks for all user interactions between the two fragments and the activity. One item in particular I am most interested hearing feedback on is how to align two views and then have the lower slide over the view when the user starts scrolling. Notice how the list (when showing) will not scroll downward.
One method I can suggest is to have both the map and the ListView in the same fragment and try this. It's the sliding drawer animation in Play Music.
For the part where touching the map shrinks the list view to a bar on the bottom. I suggest you create animations in the listView to shrink and to expand and call them on event Down and Up respectively. Here is the MotionEvent.
I would like to implement the same pull-to-refresh UI pattern used by the Twitter app.
I have been trying to use a RelativeLayout containing a ListView, but it's really slow. How can I make it as smooth as Twitter?
I have been using the Listview's onTouch callback to get the MotionEvent, detecting when the listview is already scrolled to the top and the touch is moving downwards. Then, I adjust the top margin of the listview based on the Y coordinate. But surely that's not the way to do it, as the Listview moves down in little steps, not smoothly.
Do you know which layout should be best used?
Below is just a screenshot from the Twitter app:
UPDATE:
I think I found it. I believe the smoothest implementation is by using the ListView header. So, no need to use a viewgroup like RelativeLayout. Everything could be implemented within the ListView.
Android has a SwipeRefreshLayout for this purpose.
https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
I'm trying to achieve the effect that the Google+ Android app has where there is a View that sits at the bottom of the screen, and when the user scrolls the ListView that sits behind it UP the View animates down, off screen. When the user scrolls the ListView down, even slightly, the View animates back up, on screen.
I've set up a GestureDetector, that is giving me callbacks for the scroll event on my ListView, and the callbacks are constant as I scroll so I know that part is working.
In my callback I'm trying to use the ViewPropertyAnimator to animate my y value as such:
headerView.animate().yBy(distanceY).start();
Nothing happens until I stop scrolling. Is there any way to throw this animation in with the ListView scroll on the UI thread? I get the feeling it's waiting.
I've been fighting this one also. The trick I ended up using was to replace
headerView.animate().yBy(distanceY).start();
with
headerView.setTranslationY(floatValue);
Hope this helps!
I'm using nutiteq map. I have made a sample app using this map and it works all right.
But when I put map into ScrollView container then it behaves a strange way like when I touch map for navigate, it is unexpectedly zoom out and zoom in and all that.
It is only happen when I put map into scrollview container. In another view it works all right.
I want to use it with scrollview container but I can't because of this issue.
ScrollView has some special touch events and states (like Cancel touch) which were not handled in earlier versions, but are handled if you take the latest version.
Another issue of ScrollView what you may get is that scrolling is canceled after some panning, as View/Layout controller thinks that user wants to scroll whole view, so MapView does not get necessary events, it just gets Touch cancel. Maybe this can be resolved with Android view parameters.
I want to create an Android application that has a MapView at the top of the screen and a horizontal scroll view at the bottom. The data that are going to be shown on the map should be displayed at the bottom scroll view(horizontal scroll view).
Data that are current being displayed at the bottom of the scroll view will be displayed on the map as a pin. So if users scroll the bottom scroll view then the pins(represent the data on the map) will be changed associate with the data from the bottom scroll view.
I have a background with iPhone development and I am a kinda newbie for Android. Any tutorials or samples that might help for this case? Thanks in advance.
Start with the android google map tutorial.
It will explain you how to deal with maps and markers
and this one for a similar design with buttons
And in order to draw buttons on a mapview, you have to use this trick.
You will already be on the right track.
And for the list (use a list view in android), it depends where your data are from, use either a cursorAdapter (database) or arrayAdapter (memory data).
Regards,
Stéphane