I'm trying to implement a "swipe" animation when opening a fragment.
Right now When the fragment is being shown from my MainActivity the fragment is being scrolled down (top-to-bottom), going over and covering the Activity.
What I'm trying to achieve is that instead of the fragment being rolled on top of the activity I want it to "push" the activity out of the way on its way down. Similar to how ViewPager animations work.
Here is a rough sketch of what I'm trying to achieve
From my limited experience with ViewPager, it can be used to "Swipe" between multiple activities OR multiple fragments, and you cannot mix & match.
Does anyone have an elegant solution on how to achieve this?
I really don't want to convert MainActivity into a fragment because there are tons and tons of code there.
Thanks in advance <3
In this case you need a BackDrop component.
for more information see the website below:
material.io
but there is no proper implementation in android you must implement this component by your own
you can use these website below to implement this component
medium.com
github.com
Related
I am planning to start an app from the scratch and I need to know wheather a COMMON Navigation drawer is applied through out multiple activities without using a fragment inside the activity.
I tried many examples but none worked for me. Any help should be greatly appreciated.
Yes it is possible create one base activity and implement the drawer in base activity like here. and extends that base activity
As far as I know it is not possible. I've personnaly used a single activity hosting a navigation drawer instantiating differents fragments to swipe between them.
Here if you wanna do it: http://developer.android.com/training/implementing-navigation/nav-drawer.html
The best you could have to get kind of the same result with activities is playing with transitions params in each of their class. It is kinda heavy. Use fragments for this purpose.
The following topic could bring you some work elements if you still wanna do it: Android how to add swipe Gesture on LinearLayout without onDown true
But keep in mind that it won't be as smooth as the navigation drawer with fragments.
As far it's not possible without using fragment. and why you don't want use fragment.?
Fragment is a best thing to achieve this.
Here i am attached some links.
I hope that links are use full for you.
https://www.learn2crack.com/2014/05/android-working-with-fragments.html
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
In android, i want to move from current to previous activity by left to right swipe as in iOS. I want to be able to even hold while swiping such as both activities are visible at the same time.
I want to introduce transition/animation effect just like in Telegram app. So please help how can i do it.
Tutorials or example code will work for me.
Thanks in advance!
You better use the Swipe animation with multiple Fragments inside one Activity: Creating Swipe Views with Tabs
take a look at this tutorial : HOW TO IMPLEMENT HORIZONTAL VIEW SWIPING WITH TABS
If you're already using Google's NavComponent library, you should try a library that I wrote:
https://github.com/massivemadness/Fragula
It's fully integrated with NavComponent, which means the navigation API stays the same, you only need to make some changes in NavGraph and NavHost container.
Here's the result:
I have a design for an app that will have a row of buttons below the action bar. Each button will open a different fragment. I am aware of ViewPagers, but I do not want the swipe between fragments functionality. I know that I can disable this functionality, but at that point is it worth using a ViewPager? I know this is a pretty common design paradigm, so how do most apps handle this sort of thing?
It seems like the ViewPager will provide some nice functionality out of the box, like switching between fragments and what not. So, I am leaning towards using one, but was hoping someone could provide some feedback on this approach.
Thanks!
Keep the buttons in the layout of your main activity. Have them call a function lets say loadFragment(Button button) on click.
This function then handles switching of the fragments, and you can change the display of the navigation buttons inside this function itself to highlight the appropriate button or something equivalent.
Google Design is always worth the reading.
Check http://developer.android.com/design/patterns/swipe-views.html for details.
Personally I have used ViewPager with tab layout for swiping purpose and it makes it easy to me to synchronise the transitions ( tabs and pages) where I put a red circle to the tab corresponding to the viewed page. With this approach I got a clean separated code.
I have to deal with two ActionBar displayed at the same time on the screen. There's an onClickListener on the second one which allows the second activity to be shown on the entire screen after a click, with an animation.
I have no idea how to do that. Two activies, fragments? ViewPager? ... Absolutely no idea. Could you please help me? Thank you.
EDIT : here is a picture of what I wanna achieve http://romainpellerin.eu/so_android.png
You have to see it in order to clearly understand my problem.
Definitely Fragments.
When you bring in the second fragment specify animations in the fragment transaction before you commit it.
There are tons of tutorials online. Here some more help.
Android Fragments and animation
SDK
http://developer.android.com/guide/components/fragments.html
how to make fragments backwards compatible
http://developer.android.com/training/basics/fragments/support-lib.html
Can someone tell me how do the following works:
in an application there are something like header with titles. So you can scroll the screen down to see all its information and then throw it to the left and see another screen, like with messages.
This functionality of vk.com
Sounds like what you are after is a ListFragment and a Fragment used with a ViewPager.
The ViewPager gives you the funcionality of swiping left and right, and the Fragment class is a really good way of implementing things, since they are reusable and can be placed in different activities.
have you tried to use ViewPager? You can see it's functionality in Play store application.
You need use class ViewPager. My advice - use fragment.