Android Gridview with different sizes - android

How to make a GridView look something like that?
I found similar library but it is implemented using ListView and I want using RecyclerView.
Thanks.

To do this use RecylerView and StaggeredGridLayoutManager
recyclerView = findViewById(R.id.recycler_view);
mAdapter = new YourAdapter(yourParameters);
recyclerView.setLayoutManager(
new StaggeredGridLayoutManager(spanCount /*in your case number of columns*/, StaggeredGridLayoutManager.VERTICAL /*orientation*/));
recyclerView.setAdapter(mAdapter);

Related

Android ListView animation when scrolling (iOS Style)

I would to copy the iOS Pickeron Android with the animation while scrolling.
There is an example:
.
I found some answershere and here that's not what I want.
Any help would be appreciated.
You can use CarouselLayoutManager to achieve this look, with this library you will have one elevated item that will be above all others and this will give your list the desired look.
How to use:
In your gradle:
implementation 'com.azoft.carousellayoutmanager:carousel:version'
When declaring an adapter:
final CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.VERTICAL);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
You can also use Android-PickerView library or WheelPicker, I have only worked with the first suggested library above so I don't know how those 2 will work for you.

Show multiple text labels in a Horizontal recycler view/carousel view

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.

Recyclerview with rows and columns?

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.

LayoutManager with dynamic column count

I currently have this RecyclerView in Android:
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
mAdapter = new MyAdapter(mList);
mRecyclerView.setAdapter(mAdapter);
I am trying to reproduce this layout:
A list of cities (tiles of different width) in a vertical RecyclerView. I would like the tiles to be left aligned and go on new line only when there is no free space for the next one.
I don't know how to create a custom LayoutManager for my needs.
All help will be appreciated :)
I think ChipsLayoutManager is what you are looking for.

How could scroll HorizontalListView automatically

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

Categories

Resources