Element like a PageView in android - java

I'm creating an app for both Androids and iOS. In a view, I'm using a pageView as a subview (I mean it doesn't fill all the viewController) in the iOS app.
I need to implement the same thing in Android and I don't know what element I should use.
Here you have an example of a page view.
Thanks for the help.

you can achieve this using view pager
ViewPager Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows.
follow this link to implement view pager
link 1
link 2
link 3
link 5

The equivalent in Android is a ViewPager.

Use a ViewPager with multiple fragments to get the same effect.

Related

using The same RecyclerView for two Tabs in android

I have a RecyclerView and two Tabs in my MainActivity. I just want to show another data in RecyclerView when each Tab gets selected. for doing this should I use ViewPager for Tabs? should I use Fragment? I really don't know. Are they needed in my example? the only difference between tabs is just the data they show to user inside RecylerView. RecyerView is the same. Toolbar is the same , etc. Can anyone help me? Thanks
First off yes you will need a ViewPager. This ViewPager will require you to use Fragments. Take a look at this example from the official docs.
To solve your RecyclerView problem you have two options:
define a custom RecyclerView (by extending Androids RecyclerView)
defining a custom RecyclerViewAdapter and use it with a RecyclerView
I would advise you to do the first if the RecyclerViews are completely similar. Then you could define all your properties with it, without having to do that twice in your Tab Fragment. Otherwise take the second option.
Have you looked at using Conductor?
Conductor
Why I choose Conductor over Fragment?
It is a cool replacement for Fragments.

Bundling in Recyclerview- Android

I want to create a simple view like this. (red circle)
I searched on internet for Bundling in Recyclerview but I could not find any resources.
Can anyone tell me the name of this view or share any tutorial resources.
Can someone share an example of how to do it. Or any Tutorials on how to get this view . - Bounty question
In recyclerview you can do this with item decoration.
An ItemDecoration allows the application to add a special drawing and
layout offset to specific item views from the adapter's data set. This
can be useful for drawing dividers between items, highlights, visual
grouping boundaries and more.
All ItemDecorations are drawn in the order they were added, before the
item views (in onDraw()) and after the items (in onDrawOver(Canvas,
RecyclerView, RecyclerView.State).
refer here
or
you can design a custom layout and inflate it using getViewByType in
viewholder
I think you better to follow this videos, i am sure my side this videos gives you a perfect idea on Android Recyclerview and also provide a solution for problem.
Please follow this youtube link: https://www.youtube.com/watch?v=XhbsNO2_oDI
ItemDecorator from example below doesn't suite you. Try to use Expandable Listview, which helps you to adjust list, when user tap on image below list item, and expand size for another item, for example, chat messages in your image.
Use This Example!

how to scroll live cards in aglass activity

I'm writing a glass app.
In one activity I want to scroll between few cards (which were popups in my android app).
1) I thought to use cardsScrollView.
problem: Is it possible to set customView to a card object?
2) I thought to use LiveCard
problems:
Is it possible to publish them inside my app and not in the timeline?
Is there an equivalent LiveCardsScrollView?
Any other idea how to implement this?
From Google's sample code at https://developers.google.com/glass/develop/gdk/ui/theme-widgets and API documentation at https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/widget/CardScrollView and https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/widget/CardScrollAdapter, it seems your 1) is possible, because:
1) The CardScrollAdapter's method public View getView(int position, View convertView, ViewGroup parent) returns a View (not a Card);
2) CardScrollView's get methods also return a View or Object, not Card specifically;
3) You can replace private List<Card> mCards; in the sample code (link #1 above) with private List<MyView> mViews;
But the documentation at those links also use Card as example, and the word cards seem to refer to static cards. So will have to test to find out for sure. However, there's a statement in link #1 that says "You can build a standard view hierarchy yourself or use the Card class.", suggesting it's possible to use a custom view.
I'll get back with you within 12 hours after I test with my Glass tonight.
As for your question 2, the answer is yes - you publish the scrollable content inside your app and not in the timeline. You can launch the activity (as in the sample code in Google's link #1) from a menu item selection, and the menu is attached to your livecard. Then inside that scrolling view, you can only swipe left and right to see other cards (or maybe custom views) in the scrolling view, but not the timeline. You have to swipe down to exit the activity (immersion) to go back to livecard, then you can swipe left and right and see the timeline. Note the scrolling view is not like static cards and will never show in the timeline. Also note that inside the scrolling view, you may use GestureDetector to capture other gestures (besides swipe left and right and down).
Just confirmed: custom views can be added to CardScrollView! I used a view that extends FrameLayout and inflates a layout xml file, and added three such views to CardScrollView. It works nicely!
Also tried to add a custom view that does the Canvas drawing, but haven't been able to see it shown in the scrolling view. Will try more later.
Just tested and found you can add any views to the CardScrollView - I'm able to add 4 custom views to a scrollview: one static Card, one view with Canvas drawing, one with OpenGL ES 1.0 drawing, and the final one with OpenGL ES 2.0 drawing. This is good to know to me! Thanks for your question.

ScrollView screens similar to main menu in android

i am trying to add a scroll screen layout in my app just similar to main screen scroll of any android mobile. How can i Add such a screen in my activity.
Check the image below.
You can do this by using ViewPager. The ViewPager is also included in the Support library, so you can use it on HC< . It works excactly like this.
There are also custom implementations of the ViewPager, which increases its possibillities e.g.: The ViewPager from Jake Wharton.
This can be done by using "SwipeView"
A SwipeView is an Android UI view similar to the homescreens. You have several similar panes of content that you access by swiping left and right.
You can either go with Android ViewFlow or ViewPagerIndicator
Use Jack Wharton's ViewPagerIndicator, it should work for you.
https://github.com/JakeWharton/Android-ViewPagerIndicator/

Android layout in java code

i'm making an app that requires indefinite textviews and images. i'm trying to implement a Pulse News app UI but having a hard time implementing one. so i thought of an idea to make a UI like that with the use of textviews, imageview and horizontal scroll view.
textview string values are from parsed xml online and images or the imageviews will be images from a specific directory in the sdcard that my app is using.
can anyone give me ideas how can i do it without using an xml layout or is there any or other options or ways for doing this? thanks...
You can create a viewgroup with one textview and an image. Then it can be added dynamically to your layout many times. This can be done by creating objects in a loop. You can change the content in each viewgroup at the time of inflation.
though i dont know what exactly how pulse new app looks like, but by going through your question (horizontal scroll view in particular) I guess you want to implement a "Gallery" type implementation where in you can swipe left/right on page basis.
If my assumption is correct then you will like to see to ViewPager of android backward compatiblity pkg.

Categories