I'm making a new app that has a layout as follows:
LinearLayout1 LinearLayout2
Breadcrumb
Main Content
When user clicks "linear layout2", the screen will slide left until "linear layout1" is hidden. Then a new activity with title is "linear layout2" will be shown.
When user clicks "linear layout1", the screen will slide right until "linear layout2" is hidden. Then a new activity with title is "linear layout2" will be shown.
I do some researches but cannot find a solution. Could you please give me some tips and examples so that I can go ahead?
Thanks
Your question is slightly confusing so I'm going to make an assumption.
Is [LinearLayout1 LinearLayout2 Breadcrumb] suppose to be navigation or tabs that when selected insert their corresponding content into the Main Content?
If so I would suggest using fragments for each piece of content. Then when you click the navigation/tab, perform an animation of the fragment which slides the content in and out.
See the google docs for how to use fragments:
http://developer.android.com/guide/components/fragments.html
See another stackoverflow answer for how to do the slide animation:
Android Fragments and animation
Related
I'd like to build an app that has what I understand top be a three top level screen hierarchy like this:
That is, Master screen displays different sections with different content, comprised of items that can be articles (green) or videos (blue).
Clicking on an article (in any of the sections) would take you to a detail screen (top right, in yellow) that should maximize reading area, with a topbar with a back/close button, and covering the bottomnavigationview. Going back (or up) takes you again to the screen with bottomnavigationview.
Clicking on a video would launch a different detail page in which the video can be dragged to the bottom as shown in bottom left screen, so you can still operate with the master list of items (or whatever lies beneath).
Either clicking on an article item (green), or clicking on a video item on top right (detail of an article), would take you to what is shown on bottom right; that is, video detail over article detail. Video then can be dragged to reveal underlying article and still be operable.
Now I already have a fragment that implements the dragging behavior of a video detail, that is not an issue.
My problem comes with understanding how to architect this with Navigation Component. My naivest approach would be ditching the nav component and have on my activity three fragment holders, one for the bottomnav content, one for the article detail, one for the video detail (which has to be above everything else), but getting rid of the nav component means i have to implement such things as backstack and deep linking myself.
Is this kind of navigation flow possible with navigation component? If anything, I'd like at least to get the master-article detail implemented with NavComponent, and separate the video implementation in a differnet fragment holder.
I have an activity which contains a ViewPager which lets me swipe between four pages and a RelativeLayout at the bottom containing tabs for the pages. I was wondering if it was possible to make it so that when I drag the bottom RelativeLayout up it starts a new activity ending the ViewPager activity.
Added horrible diagram to help explain
I think this link will help you.
slide up xml animation on change activity in android
You can just change the animations X and Y values to create Slide Up animation on startActivity.
In google play, if you enter a screen that uses tabs, you can notice how you can scroll each tab but the panel that seen to contain the tabs also moves vertically to a certain extent. I can imagine that it accomplishes the movement of the tab panel with a TranslateAnimation and a layout animations. But what I can't understand is how it decouples the content of the tab from the tab panel.
To answer the decoupling of the tabs and content question; I have implemented this before using 2 sets of tabs. One is in the content as a list header, the other is layered on top of the list in a containing FrameLayout so it's 'floating'.
Using scroll callbacks you can change the visibility of the floating tabs to suit your needs. Once the list header tabs moves off the screen make the floating tabs visible, once they move fully back onto the screen hide the floating tabs.
Just ensure that every time you show/hide tabs that you copy the values for horizontal scroll position and selected tab from the currently visible tabs to the ones that are about to become visible. works a treat.
The best open-source project you can find for this Android-ObservableScrollView
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.
I have to show two tabs each containing ListFragment classes. On clicking any item of the list, it's details should open on the right panel on landscape views. This is much like the official Android fragments example.
What I want to achieve is that on the left side of the layout the list view should be in tabs, i.e. two list views within tabs. On clicking any item the details should open on the right. Till now, I can show tabs and details, but the details are not showing up on the right. They open as a new activity.
Tab Navigation can be an option, but due to some design restraints in my app, I can't use that. Please guide.
Please check this android blog http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html It has a complete tutorial of how to use fragments as a Master-Details View.
I came to a solution. I am explaining how I did it, in case someone needs it.
I wanted to make tabs on the left fragment. Due to design constraints, I could not use Tab Navigation, as I had to use List Navigation too.
So, I made a new fragment placed over the left fragment and inflated it with two buttons. On different button clicks, I used FragmentTransaction to add new fragment to the left fragment.
On button click listener I used fragmentTransaction.replace method.