How to Achieve this layout shown in below image Please suggest me how to make layout at run time while my contain is loading directly from web service.
You can use FlexboxLayoutManager for this, here is the snippet
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager();
layoutManager.setFlexWrap(FlexWrap.WRAP);
layoutManager.setFlexDirection(FlexDirection.ROW);
recyclerView.setLayoutManager(layoutManager);
And in Gradle file you will have to compile this dependency
compile 'com.google.android:flexbox:0.3.0-alpha3'
for more you can check this link here
Related
So I've spent the last few hours trying to create a horizontal scrolling Recyclerview.
I'm pretty sure that I'm following the correct techniques for setting the LayoutManager for the Recyclerview, but it just won't work. on the preview it works, but once I push it to the Emulator, it still renders the list in vertical mode instead of horizontal.
I haven't made any references/changes to the Recyclerview programmatically (I tried setting the LayoutManager before, but it also didn't work).
Screenshot showing the issue:
try adding this code to your java class in the onCreate Method
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));//set your recyclerview layout to hoizontal
also try posting your java or kotlin code next time to get better feedback.
You should call Layoutmanager from fragment/activity. If you are using Kotlin, do this
XML
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Fragment/Activity
val layout = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
recycler.layoutManager = layout
*Change this with requireContext() if in fragment
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.
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
RecyclerView is shown with vertical orientation, and can not set this property, because orientation belongs to the LinearLayoutManager object. Any way to simulate HORIZONTAL layout?
Anyway the linearLayoutManager created in code is set to HORIZONTAL.
llm.setOrientation(LinearLayoutManager.HORIZONTAL);
try to add these parameters to your RecyclerView inside your layout xml:
android:orientation="horizontal"
android:scrollbars="horizontal"
app:layoutManager="LinearLayoutManager"
RecyclerView won't show your actual data in the Editor Layout as the data you add in your RecyclerView is added Dynamically in your java code through Adapter and you implement a layout manager for your recyclerView in your java code and your Editor Layout displays the elements that are in your xml, so in your XML file its just a plain recyclerView which has no idea of what data is added in your Java implementation or what LayoutManager is to be implemented on it.
AFAIK, there is no such facility editor provide yet.
although you can set the orientation of LinearLayoutManager Horizontal at runtime, this will fulfill your requirement.
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
Is there any way to get a RecyclerView with different spanCount for every row depends on how many items can fit in a row ? Meaning when there is no more width to fit new item, it will break into a new row.
I've attached a photo so you can see what I need.
If can't be done with RecyclerView, can it be done with TableLayout ? or a listView ?
You can do this with a Recycler View and a custom Layout Manager
This article might help
http://wiresareobsolete.com/2014/09/building-a-recyclerview-layoutmanager-part-1/
(sorry I don't have code to share. ive never done this, but i think its possible to do accomplish it this way)
The solution is FlexLayoutManager:
https://github.com/google/flexbox-layout
All you need to do is to add it in Gradle (1.1.0 for project using AndroidX artifacts, 1.0.0 other way):
implementation("com.google.android:flexbox:1.1.0")
And create it like this:
recycler.layoutManager = FlexboxLayoutManager(context, FlexDirection.ROW)
You can use ChipsLayoutManager also. https://github.com/BelooS/ChipsLayoutManager
implementation'com.beloo.widget:ChipsLayoutManager:0.3.7#aar'
allprojects {
repositories {
jcenter()
}
}