android-gridlayout

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,

Set layout_column and layout_row in GridLayout programmatically

丶灬走出姿态 提交于 2019-11-26 23:22:08
问题 I have a GridLayout (not GridView) where I want to add some views with a special row and column inex. In XML I can set the View with: <TextView android:id="@+id/textView1" android:layout_column="2" android:layout_row="4" android:text="Large Text" /> But how can I set the attributes layout_column and layout_row programmatically? I want something like this: GridLayout grid = new GridLayout(getActivity()); grid.setColumn(2); grid.setRow(4); grid.addView(new Button(getActivity()); 回答1: The

Android - Gridlayout android.support.v7.widget.GridLayout cannot be cast to android.widget.GridLayout

左心房为你撑大大i 提交于 2019-11-26 21:45:25
问题 I want to create a GridLayout able to run in all the APIs. The thing is, when i use GridLayout instead of android.support.v7.widget.GridLayout the app runs fine in Android 7.1.1 but in older versions it crashes. But if i use android.support.v7.widget.GridLayout instead of GridLayout (like the code below) it always crashes. activity_main <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res

GridLayout and Row/Column Span Woe

Deadly 提交于 2019-11-26 21:21:26
The Android Developers Blog post introducing GridLayout shows this diagram of how spans impact automatic index allocation: I am attempting to actually implement that using a GridLayout . Here is what I have so far: <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.commonsware.android.gridlayout" android:layout_width="fill_parent" android:layout_height="fill_parent" app:orientation="horizontal" app:columnCount="8"> <Button app:layout_columnSpan="2" app:layout_rowSpan="2" android:layout_gravity="fill

GridLayout(not GridView) - Spaces between the cells

时间秒杀一切 提交于 2019-11-26 17:12:34
问题 I am using GridLayout (support) for displaying ImageView s in my application. There are 3 columns and 5 rows. The problem is that the cells in the GridLayout automatically get some space between them. I am not setting any padding or margin for the cells. Please refer to the image below. All cells are added dynamically and here is how I add these cells. Getting Screen Width and Height: Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); screenWidth = size.x;

GridLayoutManager - how to auto fit columns?

可紊 提交于 2019-11-26 15:18:42
问题 I have a RecyclerView with a GridLayoutManager that displays Card Views. I want the cards to rearrange according to the screen size (the Google Play app does this kind of thing with its app cards). Here is an example: Here is how my app looks at the moment: As you can see the cards just stretch and don't fit the empty space that is made from the orientation change. So how can I do this? Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System

gridView with different cells sizes, pinterest style

不羁岁月 提交于 2019-11-26 12:38:39
问题 Background GridView is a class that extends AdapterView , which means it shows cells in a grid-style efficiently, recycling old views to be shown as new ones when the user scrolls it. The problem Sometimes, you would want to get a special UI, which resembles the Windows Phone Tiles UI, having cells of different sizes on top of each other. Something like this: AABB AACC AADD AADD each letter represents a part of its cell, so cell A is 2x4 , cell B and cell C take 2x1 each , and cell D is 2x2 .

Android GridLayout with dynamic number of columns per row

▼魔方 西西 提交于 2019-11-26 08:53:19
I have cards with different width and I would like to create a Grid Layout where width = match the parent (filling the screen) and fixed height. I would like to set the cards in the Grid layout so the number of columns changes accordingly to the width of the elements that can fit the row. So the elements will be set in a horizontal row till they can fit the screen and then go to the next row, with a vertical scroll when they exceed the fixed height. I am trying to use a Grid Layout but I don't know if it the suitable solution for this. I use native Android . Here a picture of it should look

RecyclerView GridLayoutManager: how to auto-detect span count?

老子叫甜甜 提交于 2019-11-26 08:43:29
问题 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

GridLayout and Row/Column Span Woe

廉价感情. 提交于 2019-11-26 07:55:04
问题 The Android Developers Blog post introducing GridLayout shows this diagram of how spans impact automatic index allocation: I am attempting to actually implement that using a GridLayout . Here is what I have so far: <android.support.v7.widget.GridLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:app=\"http://schemas.android.com/apk/res/com.commonsware.android.gridlayout\" android:layout_width=\"fill_parent\" android:layout_height=\"fill_parent\" app:orientation=\