I would like to implement the following behavior in an android application:
So should I use fragments with horizontal ScrollView, a ViewPager or what exactly? Would it be better to use CardView?
And how to add the 2 dots at the bottom to show that we still have for example another page to show?
Finally, I need only one fragment/CardView to be present at a time. That is, I don't want to see half of the first fragment and half the second. That would be annoying.
I would like to know in general what pieces to use for this purpose.
Any help is much appreciated!!
I would use ViewPager. It will give you all of the functionality you're looking for and will allow you to add or remove pages easily in the future.
You will have to manually create a page indicator (the dots at the bottom) or use a library like this:
https://github.com/romandanylyk/PageIndicatorView
Related
I am making an app and want to make sure I am following good practices before I proceed further and potentially turn my app into a "big ball of mud" implementation.
So right now the general idea I have in my head is where you have a row of icons along the top representing the different pages you can click on. You click the button/icon and it takes you to that page.
So this icon-row along the top would be constant throughout most of the app. The only thing that would change would be the contents below that icon-row.
Is it considered acceptable practice to use fragments here? Use one main activity that has the icon-row at the top and then have the container below that "swap out" fragments based on the icon clicked? And then each page is really just a big fragment?
Does this make sense, am I following good practice? Is there a better way to do this?
I am making an app and want to make sure I am following good practices before I proceed further and potentially turn my app into a "big ball of mud" implementation.
If that happens, try a good brand of laundry detergent, at least if you are using Twitter Fabric.
So right now the general idea I have in my head is where you have a row of icons along the top representing the different pages you can click on. You click the button/icon and it takes you to that page.
A typical implementation of that in mobile apps is to use tabs that contain your icons.
Is it considered acceptable practice to use fragments here? Use one main activity that has the icon-row at the top and then have the container below that "swap out" fragments based on the icon clicked? And then each page is really just a big fragment?
Most modern tab implementations are based around using a ViewPager as the container for the tabs, so the user can swipe the content or tap on the tab to switch to different pages. ViewPager can work with plain views for its pages, but the stock PagerAdapter implementations use fragments.
Even if you elected to eschew tabs, using fragments for the pages (whether wrapped in a ViewPager or not) is reasonable.
The big thing to watch out for is memory consumption. Android devices do not have infinite RAM.[citation needed] You need to make sure that you have a modest number of fragments outstanding at any given point.
Yes, this is the proper way to use the parent activity or fragment with this "icon-row". You can use the Toolbar+menu for example, if you want to preserve the Android look, use tabs+ViewPager or use custom view.
Then, in this activity/fragment you will have a layout that will work as a fragment container. In this layout you can replace the fragments dynamically using the FragmentManager of parent activity/fragment. Each of these pages is a separate fragment.
So yes, this is good/common practice.
You may read the how-to about replacing fragments here
I'm having a design issue. I'm not sure if this is a good way to do it but here is what I want to do.
I want a way for the user to quickly swipe or click on a button to change the data that is shown in a fragment which contains a list. I thought of using tabs but it seems that's more suited if you have different fragments for each tab and using only one fragment might not be best practices.
The reason I only want to use one fragment is because that code will not change for different tabs only the data that is given to the recyclerview.
Should I go forward with this or is there a better method?
I need to make an application that will basically be a 5 "page" quiz with true and false buttons. I don't think that a new layout/activity is needed for each "page". That would be overkill. Would a fragment or ViewPager be appropriate? Does it break any Android Guidelines? They both seem to make sense to me. Maybe fragments a little more because of a tablet/alternate layout. Any ideas would be appreciated.
I've been using the ViewPager in one of my projects, for side swiping between similar yet distinctly different views.
It is working very well.
It depends on your flow. View Pager will work well if your users can randomly go through the views. If you want things to be in a specific order then ViewPager probably won't work.
you can achieved by creating 5 pages dynamically and load that in single layout/activity
By using dynamically load pages helps In future you want to add 2 pages of question its easy to do
According to your flow u can use the this also In same activity you can change the question just on click of button.
And if you want user to revisit all question u can use view pager.
I would like to develop a Dialog which is composed of 3 steps to guide the user when he launches the app for the first time.
The following image is an example of what I would like to achieve:
1- I would like to know how to add a mark to close the dialog at the top-right corner?
2- How can I implement the small circles at the bottom of the screen that indicates the current step? Can they be created programmatically?
3-Only to be sure, I decided to navigate between the Dialog steps using a ViewFlipper. Is this the right approach?
Thanks in advance.
I would like to know how to add a mark to close the dialog at the
upper right corner?
Don't do that. That looks like it was a straight port from an iphone app. Use the native android dialog containers/buttons.
How can I implement the small dots at the bottom of the screen that
indicates the current step?
What have you tried? There's a million ways of doing this depending on the rest of the workflow.
Only to be sure, I decided to navigate between the dialog steps using
a ViewFlipper. Is this the right approach?
Maybe. It depends what you're displaying. If you're only displaying a single image or something simple, then that might be the best approach. I would create different dialog fragments ( you are using fragments, right?) for the different steps. That way you can automatically push them to the back stack as you move through the workflow.
one of the ways to implement the "little dots on the bottom" is :
include the dots in every image you are creating.
draw one of the dots highlighted in every image
flip through the images in order of the highlighted dots. (or highlight the dots in the order you want to show your images)
but this would make your dots disappear during the images are flipped.
if you want to avoid that :
create two different image views , one acts as a container for the main image, the other as a container for the dots, place the 1st image view above the other.
create a no of images containing just a no of dots, each with one of the dots highlighted
flip through both the imageViews in synchronization
use a "flip animation" in the upper image view
use no animation, or a minimal animation for the dots.
This will produce the desired effect. Hope this helps :-)
I don't know if it's a dumb question because it is one of my first apps.. but if that's the case, please also explain why!
If I create a Tab-Based Activity-Structure, I get nearly what I am asking for but only for Tabs. What I want is generally opening a second or even third activity in one main-activity which contains the main-interface.
Example: I have a Title-Bar and a little icon at the bottom-left corner for some reason during the whole app runtime. Now: How can I control them with the main activity and open at the same time some other activities/views into the existing interface? It should then be shown below the title bar and lying underneath the little icon (the icon is not really important, just fictional). Also it would be nice if I could add some fade in effects to these embedded activities/views. Is that somehow possible?
I currently only know, how to open activities each over another filling the whole screen, except in the case of tabs... maybe I only haven't inspected the tab structure enough.. however, I would be delighted about each answer!
Regards
What you are looking for, are Fragments.
Fragments can be used to fill a part of the screen, while doing something else entirely in a different one.
In your example you can create a main activity that contains two Fragments. One Fragment controls the title bar, the other one controls the main content area.
By replacing the current Fragment in your content area with a different one on the press of a button, you can achieve the behavior you are looking for. At least, that's how I did it in an app of mine containing a main content area and a music player. The music player stays in place while the main content changes.
Sadly I can't provide any example code right now, but here is a tutorialthat should help you get started:
Android User Interface Design: Working With Fragments