This may be a very juvenile question, but this has been driving me insane the last few days. I currently have an app that has 3 tabs. I would like to update it so you can swipe left and right to view each tab (as opposed to touching each tab). I have found a ton of methods on doing this, but I'm still very confused. I have been told to implement an Action Bar with Tabs as well as fragments, and I have found other sources that use Page Viewers. Either way this has been a thorn in my side to find something that is what I need. Is there any good documentation on doing a basic left and right swipe using tabs? I'm very sorry if this question is repetitive to others.
I really think that a ViewPager (as described here: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html) is what would be best for you.
And yes, it involves fragments.
Related
I'm extremely new to java and coding for Android (new to programming in general). I haven't programmed much before so I wasn't able to think about this and whether or not I'd be able to implement when I first started designing this app. I would really appreciate some help or guidance, or at least pointers. I'm sorry if this is a really stupid question and thanks in advance for all answers.
Mockup
Here is a mockup of the layout I want to create. It mainly cosists of a List, which displays information and images. (Should be ScrollView so that it can go up and down?)
Below is a button which will send information to another Fragment or Activity.
Both these layouts need to be part of an ImageView, able to be swiped left and right. Also need to add circle indicators (I've seen libraries that are capable of helping me achieve this)
There is also a Navigation Drawer at the top left which I will try to use RecyclerView with.
And lastly, there is a bottom navigation bar, which I'm currently able to do by using a library from com.roughike:bottom-bar:2.3.1 and navigating between different Fragments.
Please give me some advice on what to do or some pointers on how I might go about creating this sort of layout.
Thank you!
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'm trying to figure out navigation in the app I'm making, and want it to look like it does on the phone to the right (link below), except I want the menu at the bottom to be directly below the tabs. I tried googling and searching for hours, but I cant seem to figure out.
I have managed to make the tabs (with Fragments and such).
I apologize if this really isn't that hard, but being new to this it is kind of hard to wrap your head around everything. Either way, thanks.
I think you are looking for a custom layout.
http://www.vogella.com/articles/AndroidActionBar/article.html
Look at section 5, should be pretty simple from there.
That being said, don't fight the OS. I always ask myself questions like: Do you really need tabs above a menu? Can you quote another application doing that?
I know that we can place tabs on our convenient with top alignment or bottom alignments.But when i was reading the developer.android.com.The training section for lateral navigation has emphasized on the fact that tabs should not be used at bottom of the screen.But i don't find any reason why they are insisting someone to not use tabs at bottom.
Can any one explain me?
you can find this article here
you can find that lines below figure 5 at the end of the paragraph.
advance thanks for giving attention to question.
Consitency: It is at the top in most apps
Usability: If you use eye trackers you see that users read a page from top to bottom. If the tabs are at the top they are easier to find.
Option menu: There is already an option menu at the bottom.
It's very simple, it's all about UserInterface Concepts (there are many out there, android has an own: http://developer.android.com/guide/practices/ui_guidelines/index.html ). One of them is "Consistency" - we users expect tabs (especially in android, but also in browsers) at the top and that's why they should stay there.
Also there are a few "famous" rules for userinterfaces.
One set for example is from Shneidermann: http://faculty.washington.edu/jtenenbg/courses/360/f04/sessions/schneidermanGoldenRules.html
I'm no expert, but I'd think it's simply a matter of convention. Users would probably expect tabs to be towards the top of the page. It's comparable to putting a file menu to the far right of a menu bar rather than the left.
My goal is to create a screen similar in function to the Stream page in the Google+ app (picture below for those unfamiliar). For the paging, I am using a custom ViewGroup so that it has smooth transitions that "follow your finger" rather than just snapping to the destination after the fling gesture has been made.
Question
Currently, I am going the route of using some TranslateAnimations to move the headings ("Nearby," "All circles," and "Incoming" in the screenshot) once a new page has been selected. This creates a couple of problems: the center heading doesn't follow the user's finger (as you can see the "All circles" heading does in the screenshot), and if the user begins on a page other than the middle one, I have not found an easy way to offset all of the animations temporarily without running them first since the animations do not move the actual views.
Am I going about this the correct way, or is there a much simpler way of accomplishing this that I am overlooking?
Thanks
After hours of searching and a little luck with search terms, I came across A Google+ like ViewPager page indicator.
I also came across Android ViewPager Indicator, created by the same developer who wrote ActionBarSherlock. Has a ton of examples, and is pretty easy to integrate with the FragmentPagerAdapter.
Google has published his own solution in support library.
Check:
PagerTitleStrip,
PagerTabStrip
Have just used ViewPagerIndicator solution and its very nice and smooth. You can demo the effect by looking at the demo from the Android Market here
I am not 100% sure, but I think it uses the new ViewPager.
Maybe you should look at the API 4+ Support Demos:
FragmentStatePagerSupport.java
FragmentPagerSupport.java