gridlayoutmanager

Different (dynamic) items height in GridLayoutManager

99封情书 提交于 2019-12-29 06:13:08
问题 I have a RecyclerView and GridLayoutManager with 2 columns. How can I force LayoutManager to be according with template on the first screenshot? Now I have result as on the 2th screenshot. Need result: Current result: 回答1: GridLayoutManager will use a grid, and you can set some span, but not different heights for different cells. What you want is a StaggeredGridLayoutManager. This will just put the items on the screen if they fit, leading to your needed result. You can also change the

Square layout on GridLayoutManager for RecyclerView

给你一囗甜甜゛ 提交于 2019-12-28 03:29:09
问题 I try to make a grid-layout with square images. I thought that it must be possible to manipulate the GridLayoutManager by manipulating onMeasure to do a super.onMeasure(recycler, state, widthSpec, widthSpec); instead of super.onMeasure(recycler, state, widthSpec, heightSpec); but unfortunately, that didn't work. Any ideas? 回答1: To have the square elements in my RecyclerView, I provide a simple wrapper for my root View element; I use the following SquareRelativeLayout in place of

RecycleView's span size

白昼怎懂夜的黑 提交于 2019-12-23 15:50:42
问题 I'm trying to achieve a layout similar to the picture above with the RecyclerView in conjunction with the GridLayoutManager, i tried setting the setSpanSizeLookup based on position but couldn't mimic the design above.. anyone could help please? mRecyclerView = (RecyclerView) contentView; mRecyclerView.setHasFixedSize(false); GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 3); gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override

How to give space between gridview in through java

ぐ巨炮叔叔 提交于 2019-12-20 04:37:26
问题 How do i get perfect aligning between the gridView items, i have added the gridview using java and it's base adapter is set in which i added the image and textview. Xml Code: <android.support.v7.widget.CardView android:layout_width="180dp" android:layout_height="200dp" android:layout_margin="5dp" android:orientation="vertical" app:cardCornerRadius="5dp" app:cardElevation="5dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical

android - how to catch Drop action of ItemTouchHelper which is used with RecyclerView

萝らか妹 提交于 2019-12-17 18:13:08
问题 I have a problem with ItemTouchHelper of RecyclerView . I am making a game. The game board is actually a RecyclerView. RecyclerView has GridLayoutManager with some span count. I want to implement drag & drop recyclerview's items. Any item can dragging over all directions (up, down, left, right). private void initializeLayout() { recyclerView.setHasFixedSize(true); recyclerView.setLayoutFrozen(true); recyclerView.setNestedScrollingEnabled(false); // set layout manager GridLayoutManager

Set span for items in GridLayoutManager using SpanSizeLookup

不羁岁月 提交于 2019-12-17 04:46:52
问题 I want to implement grid-like layout with section headers. Think of https://github.com/TonicArtos/StickyGridHeaders What I do now: mRecyclerView = (RecyclerView) view.findViewById(R.id.grid); mLayoutManager = new GridLayoutManager(getActivity(), 2); mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { switch(mAdapter.getItemViewType(position)){ case MyAdapter.TYPE_HEADER: return 1; case MyAdapter.TYPE_ITEM: return 2;

Set height & gravity of Span item in GridLayoutManager

房东的猫 提交于 2019-12-12 04:25:04
问题 I'm working with Grid Layout Manager in Recycler View . I can : show one View Group inside Grid Layout like image below. Able to set Space Item Decoration Able to set different Span Size Lookup . My issue is : Not able to set Height of each Span row inside, as 5 small circles in above image. (I want to set smaller height) The span item can not set gravity to center when it stay alone, as Big circle in above image I tried to find method setFullSize() (exists when working with

How to make GridLayoutManager use dynamic spaces? [duplicate]

痴心易碎 提交于 2019-12-11 18:55:53
问题 This question already has answers here : Different (dynamic) items height in GridLayoutManager (2 answers) Closed 8 months ago . I am currently using a GridLayoutManager for a RecyclerView which displays Previews of different Articles, which have different text lengths and therefor different item heights. The question is, how can I use the full height and dont have too much spacing? 回答1: Use StaggeredGridLayoutManager! https://developer.android.com/reference/android/support/v7/widget

Recycler view arrange items in a grid that scrolls horizontally

寵の児 提交于 2019-12-11 16:57:46
问题 I have set of icons that I need to display in a RecyclerView arranged in a grid, and make that grid scroll horizontally. Normally I would use GridLayoutManager for something like this, but my requirements are preventing me from doing this. Namely, not only that the items have to be arranged in a grid, but they also need to be added to the grid row by row and not column by column (this is how GridLayoutManager does it). So for example, if the grid is is 3x3 and I have 4 items, they shouldn't

How to have a GridLayoutManager with header, without changing its adapter?

别说谁变了你拦得住时间么 提交于 2019-12-08 04:52:45
问题 Background I have an app that shows a list of items in a grid-like way, yet not exactly... The problem Some of the items have a different height, so the ones near them should gain the same height as they have. This one works on GridLayoutManager. Some items (actually only the first one in my case) need to span the entire row (which is why I used StaggeredGridLayoutManager ). Using the normal GridLayoutManager, the first requirement worked fine: each row could have a different height. But