Navigate horizontally and hit a button to go another layout vertically - android

I've been trying to figure out how to go about doing this specific task, but I can't quite figure out.
So, I have a ViewPager setup with 2 layouts that work perfectly. In the landing Pager, I have a button. What I'd like to do is, hit that button and the page animate vertically (up) to another layout.
I got the similar movement with starting a new Activity, but the problem with that, is that the title bar gets animated as well. So it doesn't give this fluid motion to the layout above.
I tried several things, but came up short with a lot of crashes.
Then I was thinking of having the landing Pager be a ScrollView and stack both layouts on top of each other, and navigate to a specific id, but came to no avail.
Does what I'm saying making sense? How should I go about creating something like this?
So to summarize.
Land on a page where you can swipe to one additional page (left).
Be able to hit a Button (on landing page) and animate up (vertically) to another layout.
All of this while having a static title bar.
Thanks in advance.

Related

How to swipe away an activity to finish it

I know how I can change the animation between two activities. But how about:
Imagine an activity with one rectangle in the middle. If the user presses on the rectangle and swipe to top, the whole activity should swipe top (with the same speed) and finish if the user has swiped enough. I know how I can change the transitionAnim between two activities but this drives me nuts.
Using Framelayout, setting Homescreenwallpaper behind the content and make the anim on the content could be one solution, right? Are there better ways?
Could someone advise me and/or give me some tipps how I can achieve this?

Scrolling a ViewPager programmatically, by a small amount

I have the requirement for what is effectively two activities side by side, allowing the user to scroll from one to the other, and back. I've decided that ViewPager is probably the best way to handle this, but am open to suggestions.
When the activity loads, the left hand view is displayed. I want to indicate to the user that the other view exists, by just scrolling it a small amount to the left and back again (similar to the way it's now common to show that a sliding drawer menu exists).
I've tried a number of things but have yet failed to find a method where both the views scroll smoothly together. Another way of interpretting the requirement is saying I want to programmatically fake a user flicking the page briefly.
Try calling the method fakeDragBy(float)! According to the documentation you need to first call beginFakeDrag() to initiate it and then call endFakeDrag(). This will mantain the ViewPagers default snapping behavior, so once you've revealed the other screen is there you don't have to animate the transition back, simply call endFakeDrag and the ViewPager will correctly snap back to the last screen (As long as you haven't dragged it past the half-way mark).

Android: Activity sliding over another one with swipe gesture

I have two activities one with some data and the second one, semitrasparent with some buttons on it.
I want the second activity slide over the first one after the swipe gesture.
I've already read about ViewPager and it's not what I am looking for. I want the first activity still being visible over the semitrasparent second one.
I am looking for any suggestions how to do this.
Literally not possible.
The entire point of an Activity is that it fills the ENTIRE screen, and there are never 2 of them shown at the same time, ever.
So you can't swipe to "semi" open one with a slide animation.
To do that, you'll have to use 1 Activity, and multiple Fragments.

How do I override swipe animation between two views between two fragments that are inside a ViewPager?

I've been trying to figure this out for the past week. I am an absolute beginner and have been learning stuff on my own.
So i have this ViewPager that displays fragments that have the same layout: an ImageView at the top, and a TextView at the center.
When I swipe between fragments, the imageviews and textviews get animated together and that's fine.
There are a sections however, where i want the textviews to swipe, but the image views to stay put, but will go back to swipe after one or two fragment swipes
Please take a look at this illustration:
Think of it like an iOS contacts list where a letter of the alphabet, for example "A", stays put as a header when swiping through names that begin with that letter.
I've made a PageTransformer work for the whole viewpager but when i try to do it between ImageViews, it sort of works but everything gets messed up and eventually crashes.
You can try viewpager within viewpager for the textView.
Similar question: ViewPager inside ViewPager.
Another way that I can think of is to register a listener to the textview and if the user pressed down and scroll it will check if there are more text. If there is the fragment will be replaced by the next text.
Example:
text.setOnClickListener(new View.OnClickListener()
{
ACTION.DOWN:
if(there is more text)
{
//replaced text fragment with new text;
}
}
I just added a viewpager inside a fragment, that is inside another viewpager without adding extra code to the main activity. It worked just the way i wanted it to, albeit unexpectedly. But now my navigation button skips some pages inside the nested viewpager.
Apparently, this feature has been available for quite some time.
Alright, I encountered some troubles to release my code yesterday. I'm very interested in this effect, so I've practiced this and successfully to accomplished. The whole project was publish in my github, following is my effort's result.

Right way to implement this layout?

Here's what I want to do in an app, hope it's clear:
NOTE: I don't want to have all 3 views on the screen at once!
I have a search window, I have results, and I want to show details about a result item when it's clicked.
On a small screen (phone) it's pretty clear: I show one view at a time.
On a tablet, especially in landscape mode I'd like to show 2 views at a time, means:
[search | results] and when a result item is clicked, show [results | item detail].
My ideas:
Have an Activity "SearchAndResults", when result item is clicked, open another Activity calles ResultsAndDetails. Both Activities would use Fragments, eg SearchFragment, ResultFragment, DetailFragment.
This might be quite easy to implement but doesn't seem very elegant to me, especially because I can't have any animation (let the result view slide to the left, let the detail view slide in from the right)
Have all 3 view in one activity and hide/ show them with layout.setvisibility(). No animations either, and I hate to do too much layout stuff in my code.
A viewpager that shows 2 views, but can't be swiped by the user, only from code?
What's a good way to do this?
I would use Fragments, as in your idea #1. This question seems to be describing the exact same type of layout that you are trying to implement. It has several answers on how to animate fragment transitions, including complete code examples.

Categories

Resources