Android-Appropriate View For Horizontal & Vertical Scrolling Grid - android

I am new to Android and looking for advice on which particular view or views to use for an app. I am attempting to create an epg. I have done this on another platform and was wanting to migrate to android. After alot of reading and looking at examples I am little confused. To make a horizontal and vertical scrolling grid, would the gridview alone be enough to display the program titles. I say gridview alone, I mean the gridview in the main activity with a textview in resource xml. If not can somebody point me in the right direction, not asking for code just advice on the best way to go about the project. I am not worried about a channel list or time slot list only displaying the programming title in columns and rows that can scroll both directions. I anticipate the channel list being in a recyclerview separate form the grid. Thanks for advice.

I will suggest you to use cardview. Because gridview will give you 2 dimensional view which is not more customizable. Better you can go with cardview.
For cardview, you need to add dependency. You can use cardview inside recycler view.
GridView - GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a List Adapter. GridViews are particularly useful for displaying images in a structured fashion, for example if you’re designing a gallery app. To populate a GridView with data (whether that’s images, text, or a combination of the two) you’ll need to bind your data to the GridView using a ListAdapter
CardView - To create complex lists and cards with material design styles in your apps, you can use the RecyclerView and CardView widgets. CardView gives you an easy way of displaying data in Google Now-style cards. The Android SDK doesn’t include the CardView class, so you’ll need to add the CardView support library before you can use cards in your project.
To get bettter idea, you can visit this link.

Related

What is difference between GridView, GridLayout and Recycler view with GridLayout?

I am developing an app in which i need a layout like provided images.
Which layout should i use? and why ?
What is difference between GridView and GridLayout ? why they are in legacy section ? What are alternatives and best practices ?
Following are the layout i need to develop. i can achieve this
layout many ways but i need to know best practices.
I believe I came across the same problem you had. From the google documentation websites above and this answer GridView VS GridLayout in Android Apps, I got a clue.
use GridLayout when you only want to align the position of your child view widgets. In this case, the children should not be scrolled. Grid Layout does not support recycling, which will scrap old child views that are not on the screen and recycle their view holders. You should not have too many child views, otherwise an OMM will occur!!
if it is not case 1, I believe we should use recycler view. When your children items may be in the scale of 10 + or cannot fit on the screen, you'd better use recycler view. GridView is available since API 1. If you try to click the GridView guide link in the GridView reference guide, you will be redirected to Recycler View guide website. In this website, I quote
GridLayoutManager arranges the items in a two-dimensional grid, like the squares on a checkerboard. Using a RecyclerView with GridLayoutManager provides functionality like the older GridView layout.
StaggeredGridLayoutManager arranges the items in a two-dimensional grid, with each column slightly offset from the one before, like the stars in an American flag.
Google also has sample code for recycler view at https://github.com/android/views-widgets-samples
These are the websites that I looked into:
https://developer.android.com/reference/android/widget/GridLayout
https://developer.android.com/reference/android/widget/GridView
https://developer.android.com/guide/topics/ui/layout/recyclerview
https://medium.com/google-developer-experts/android-grid-layout-1faf0df8d6f2
https://stackoverflow.com/a/11307615/10075771
this will help you understand more about gridview and gridlayout. And for my opinion, as what i see in the layout you want to achieve, its best way to use gridview.

Android Horizontal Dynamic List View

I'm trying to develop an app which is similar to e-book apps. The thing I want to do is having multiple horizontal views according to my data and listing them in a vertical view. Also, I have a view having image and title fields. I want to repeat this view inside of every horizontal view. Both horizontal view number and content of horizontal views should be dynamic. I checked it online there are some components for horizontal views but don't know which is the most useful one. What is the best way to implement this in my project?
There is a new view in android called Recycler View (perhaps you have heard about it) . It's a reimplementation of the list-view in android with lots of new features. In Recycler view, you can easily make a horizontal list view. I have found a tutorial for you on the net, The source code is included in the tutorial .
http://android-pratap.blogspot.in/2015/12/horizontal-recyclerview-in-vertical.html

Google play store like interface using recycler view

My assignment is to create an interface much same like Google Play Store.There will a Category name followed by 3 or 4 cards (horizontal) followed by More button. Then again next category.
I already had implemented this using nesting the horizontal listview inside Vertical listview.
I know, I can achieve this by using the Recycler view with LinearLayoutManager with horizontal orientation. Using this I'll be having one only row.
My question is how do I add 2nd, 3rd row to this?
Should I use again nested Recycler view?
Are there some better options?
Dont use nested listviews (you cant scroll horizontally in play store).
Consider the following options:
You can use a simple LinearLayoutManager and make different view types. For the with 3 cards horizontally use a GridLayout or LinearLayout with same weights. The problem here is, that you have to consider the indexes of your underlying data list used in the adapter
Write your own LayoutManager for RecyclerView
Use TwoWay View which is based on RecyclerView and offers a Spannable Grid Layout manager, which seems to be what you are looking for.
If you inspect the layout of the Google Play app, they do not use a listview/recyclerview for the horizontal cards. I'm pretty sure that is just a linearlayout (horizontal) within a vertical listview / recyclerview.
If you insist on using a horizontal recyclerview for each row, then having a nested recyclerview would be your best option. You can specify a RecycledViewPool so that all the nested recyclerviews share the same pool instead of creating their own.
You may like to do it as one vertical RecyclerView (Main recycler) and for every section you can inflate a horizontal RecyclerView as well (Section recycler) as this blog answer mention:
Also, consider using:
A cache layer for Bitmaps for persistent access through your other store screens
A lazy load method for your category/section images
A place holder before showing new items

GridView VS GridLayout in Android Apps

I have to use a Grid to implement Photo Browser in Android.
So, I would like to know the difference between GridView and GridLayout.
So that I shall choose the right one.
Currently I'm using GridView to display the images dynamically.
A GridView is a ViewGroup that displays items in two-dimensional scrolling grid. The items in the grid come from the ListAdapter associated with this view.
This is what you'd want to use (keep using). Because a GridView gets its data from a ListAdapter, the only data loaded in memory will be the one displayed on screen.
GridViews, much like ListViews reuse and recycle their views for better performance.
Whereas a GridLayout is a layout that places its children in a rectangular grid.
It was introduced in API level 14, and was recently backported in the Support Library.
Its main purpose is to solve alignment and performance problems in other layouts.
Check out this tutorial if you want to learn more about GridLayout.

Android TableLayout vs GridView vs Other?

I am developing an app and am looking for some general guidance:
The app is a memory trainer, and will have a couple of different modes:
Numbers: Up to 400 digits will be displayed on the screen in a gridlike pattern
Faces: Images of faces will appear, approximately 9 to a page, also in a grid pattern
The question is: can I accomplish this with a single xml layout file, and should I use the same layout type for each (and if so, what should it be!) ? It's a large app, so consistency would be heavenly.
I would prefer a layout with flexibility, and I am leaning toward GridView right now.
Any thoughts?
A Grid view is basically like a list view where items are arranged in a static grid.
It retrieves views from the Adapters as scrolled by user.
A table layout is a layout manager and does not do scrolling if required.this means u have to put it inside a scroll view. This implies that all of the data you are displaying must be populated into the TableLayout up-front, so the ScrollView knows the total space it is to scroll in. It also does not directly give you per-"item" selection or interaction, because a TableLayout doesn't have items, it is just a layout manager.
Also Adapter -based view should be used where significant amount of data is there to be scrolled. So it seems that grid view would be more suitable in the situation u r working.

Categories

Resources