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
Related
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.
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.
I am trying to design a recycler view with expandable design , it will have groups which on click would open and show child views. But the child views need to support linear layout and grid layout as well.
Currently I am using a recycler view within another recycler view to achieve the same, and used expandable layout for expanding collapsing items. This does get me the desired effect but neither is it a good programming practice and nor is it bug free. It does some unexpected things at all times, which is really annoying and a bad UX experience.
Please tell me other reliable and bug free ways to do it.
This image is approximately what I am trying to achieve. Cannot show the actual work I have done because of company policy.
I am not asking to source code to solve my problem, but some general design directions to achieve the same goal. As mentioned before, what I did, using recycler view inside another did do the trick, but also created other problems(unpredicatble behaviour to say the least.)
It seems like using nested scroll view and setting the inner recycler views to 'setNestedScrollingEnabled(false)' did the trick. Now I can make what I wanted to after all.
I am developing android v2.1 API 7 project. I know there is a good tutorial on how to implement grid view layout on Android developer website.
What I am confusing is, how can I define a layout which can be used by each cell(element) of the grid layout? Any example on this?
(For example, the tutorial have one image occupy one cell as a element in the grid view, what I want is to have a layout for each cell element instead of one single image)
extend adapter and return any view, any layout you want to show, in getView method.
I am trying to design a UI as like in an iPhone app. The image of the design is as follows
In the above image all the white boxes are of a list view. In those list view i am placing an image View and two set of text view. I have placed a overall custom list view and in that custom list view using relative layout i have place the image view and two text view.
now i want to draw a line between the two text view and when i click on the second text view i am moving to a new activity. At that time i want to show that only the second text view is been clicked.
Use a RelativeLayout:
The image android:layout_alignParenLeftt="true"
the first two textViews android:layout_toRightOf="#id/myimage",
the other textviews below the previous ones (e.g. android:layout_below="#id/author" and with a layout_width="fill_parent"
Check Romain Guy's blog post for a tutorial on a similar (simpler) setup: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
Check this http://www.androidsnippets.com/clickable-listview-items
The ClickableListAdapter bases on the
API-Demo-Example "Efficient List
Adapter". It was refactored to provide
a better reusability. Additionally,
you can connect OnClickListener and/or
OnLongClickListener to each View of
your list item. This allows you to
create complex interactive lists, or
simply using a customized checkbox
version.
I had implemented this in a project minus the image view. Heres a screenshot.