gridlayoutmanager

Changing number of columns in RecyclerView gridlayout

[亡魂溺海] 提交于 2019-11-28 06:56:26
I am trying to change the number of columns that appear in the recycler view (grid layout) based on the display size. However I couldn't figure out a proper way of achieving it. At the moment I am using treeViewObserver to change the number of columns based the change in screen size (during orientation). So if the app opens in portrait mode, number of columns (on the phone) it decides to be one, which look good but this method doesn't work when the app directly opens in landscape mode where a single streched out card in the grid is displayed on the screen. Here recList is RecyclerView & glm is

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

岁酱吖の 提交于 2019-11-28 06:47:41
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 layoutManager = new GridLayoutManager(getContext(), BOARD_SIZE, LinearLayoutManager.VERTICAL, true);

How to design spannable gridview using recyclerview (SpannableGridLayoutManager)

旧城冷巷雨未停 提交于 2019-11-28 06:18:22
问题 I want to design grid view like below image provided. The first item should be bigger than the rest. Currently I am using RelativeLayout with GridLayoutManager check below code RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view1); RecyclerView.LayoutManager recyclerViewLayoutManager = new GridLayoutManager(context, 3); recyclerView.setLayoutManager(recyclerViewLayoutManager); recyclerView_Adapter = new RecyclerViewAdapter(context,numbers); recyclerView.setAdapter

RecyclerView with GridLayoutManager trying to solve wrap_content

心已入冬 提交于 2019-11-27 18:20:05
问题 I try to solve the following: using RecyclerView with GridLayoutManager with fixed cell-widths recyclerview resizing only to the necessary height (wrap_content) I try to use the following code, the problem is that it doesn't work, and I haven't found any working example not mentioning to redraw properly when orientation changes. public class AutofitRecyclerView extends RecyclerView { private MyGridLayoutManager manager; private int columnWidth = -1; public AutofitRecyclerView(Context context)

(Smooth)ScrollToPosition doesn't work properly with RecyclerView

风流意气都作罢 提交于 2019-11-27 13:01:37
I'm using basic RecyclerView with GridLayoutManager. I observed that nor smoothScrollToPosition nor scrollToPosition works properly. a) when using smoothScrollToPosition I often receive error from RecyclerView "RecyclerView﹕ Passed over target position while smooth scrolling." and RecyclerView is not scrolled properly (often it misses the targeted row). This is observed mostly when I'm trying to scroll to the 1st item of some row b) when using scrollToPosition it seems to work quite ok but most of the time I can see only the 1st item of the row and the rest are not displayed. Can you give me

Square layout on GridLayoutManager for RecyclerView

不打扰是莪最后的温柔 提交于 2019-11-27 11:18:03
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? Anonsage 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 RelativeLayout . package net.simplyadvanced.widget; import android.content.Context; import android.util

How can I fill RecyclerView with GridLayoutManager from right to left

丶灬走出姿态 提交于 2019-11-27 02:14:00
I'm trying to fill some data into a RecyclerView with GridLayoutManager : GridLayoutManager layoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false); This will fill the data into the grid from left to right . The first item will be put into top-left place, etc. But the app I'm developing is designed for an RTL language, so I need to make it fill from right to left . I tried to change the last argument to true . But it just scrolled the RecyclerView all the way down. Also setting layoutDirection attribute for RecyclerView doesn't work (without considering that my min

Changing number of columns in RecyclerView gridlayout

核能气质少年 提交于 2019-11-27 01:37:31
问题 I am trying to change the number of columns that appear in the recycler view (grid layout) based on the display size. However I couldn't figure out a proper way of achieving it. At the moment I am using treeViewObserver to change the number of columns based the change in screen size (during orientation). So if the app opens in portrait mode, number of columns (on the phone) it decides to be one, which look good but this method doesn't work when the app directly opens in landscape mode where a

RecyclerView GridLayoutManager: how to auto-detect span count?

我的梦境 提交于 2019-11-26 23:35:34
Using the new GridLayoutManager: https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html It takes an explicit span count, so the problem now becomes: how do you know how many "spans" fit per row? This is a grid, after all. There should be as many spans as the RecyclerView can fit, based on measured width. Using the old GridView , you would just set the "columnWidth" property and it would automatically detect how many columns fit. This is basically what I want to replicate for the RecyclerView: add OnLayoutChangeListener on the RecyclerView in this callback,

(Smooth)ScrollToPosition doesn't work properly with RecyclerView

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 16:11:10
问题 I'm using basic RecyclerView with GridLayoutManager. I observed that nor smoothScrollToPosition nor scrollToPosition works properly. a) when using smoothScrollToPosition I often receive error from RecyclerView "RecyclerView﹕ Passed over target position while smooth scrolling." and RecyclerView is not scrolled properly (often it misses the targeted row). This is observed mostly when I'm trying to scroll to the 1st item of some row b) when using scrollToPosition it seems to work quite ok but