Is it possible to show multiple text in a recycler view/carousel view in android/kotlin.If yes,then what would be the logic for that or what topic should I read that will help me with this.
I have attached a example diagram below.I want to create the below part,there is some other layout on top :
Really need some help over here.
Yes, I believe you're looking for a StaggeredGridLayoutManager for RecyclerView.
For example, when setting up your RecyclerView, set your LayoutManager to a new StaggeredGridLayoutManager.
// get the reference of RecyclerView
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
// set a StaggeredGridLayoutManager with 3 number of columns and vertical orientation
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager); // set LayoutManager to RecyclerView
A more in-depth example could be found here, https://abhiandroid.com/materialdesign/recyclerview-as-staggered-grid-example.html.
Related
hi i want to make a recycler view to take items horizontal as many as the screen fit but with vertical scroll like this image as example
I try with StaggeredGridLayoutManager but it must specify the number of column want the column take as screen size any help will be good
You can use FlexLayoutManager for this kind of design FlexLayout
Here is a example snippet to use FlexLayoutManager in RecycleView
RecyclerView recyclerView = (RecyclerView) context.findViewById(R.id.recyclerview);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.COLUMN);
layoutManager.setJustifyContent(JustifyContent.FLEX_END);
recyclerView.setLayoutManager(layoutManager);
Their are many attributes to use FlexLayout Go through the documents on github
As Burhanuddin Rashid commented, you should use the FlexBoxLayout. It has a LayoutManager for RecyclerViews, so the additional code will be minimal.
https://github.com/google/flexbox-layout#flexboxlayoutmanager-within-recyclerview
Is it possible to have RecyclerView look like a grid? I.e. look like a 3x3 matrix?
The orientation can be only HORIZONTAL or VERTICAL. In iOS I can have UICollectionView have sections and rows. What about RecyclerView in Android?
Yes that is possible. You just need to replace your LinearLayoutManager with GridLayoutManager.
Before setting the adapter you need to set following lines
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getActivity(), int_value(of no of items to be in one row);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(myAdapter);
It will show int_value no of elements in one row.For a square grid(3x3), you will have to give 9 items to the adapter.
Such as ListView, it invokes smoothScrollToPosition(index)
Android Developer Doc doesn't have HorizontalListView. I downloaded this custom HorizontalListView from GitHub, but I'm confused about how to use HorizontalListView on scrolling automatically.
could recyclerview scroll loop, and it scroll in specified time
I recommend using recyclerview with a linear layout manager that is set in horizontal mode
If you need only a HorizontalListView RecycleView is the way to go.
Just add this line of code to convert it to a HorizontalListView
LinearLayoutManager layoutManager= new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
Refrence can be found here https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
you can use recycle view and set layout manager as follows
listView= (RecyclerView)findViewById(R.id.hlistview);
LinearLayoutManager layoutManager=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
listView.setLayoutManager(layoutManager);
See this example on github
How can I implement something like this so I could customize each view in the grid? (each one its own image, text.. depending on a response from server).
**I prefer not using 3-party libraries, if that's possible.
You can set up Horizontal RecyclerView, and based on the position of the view, you can set background color.
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
How to implement horizontal gridlayoutmanager with recyclerview.
Fixed row count. and horizontal scroll.
Like this...
gridLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setHasFixedSize(true);
I try do this. but this is not show anything in item.
Implement RecyclerAdapter, ViewHolder.
Instantiate RecyclerAdapter, set its' adapter.
Specify ROWSCOUNT (there are 3 rows on your picture):
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);
Set layout manager: recyclerView.setLayoutManager(gridLayoutManager);
Show your recycler view setContentView(recyclerView);
I've prepared a sample for you, check it out
I just add the affirmation. This picture might proof that Recyclerview with GridLayoutmanager is available for horizontal.