android-gridlayout

Problems with dynamic views inside recycler view

核能气质少年 提交于 2019-12-23 10:28:57
问题 I'm using recycler view to show list of items which contains grid layout of images. The grid layout is added dynamically to the list item inside "onBindViewHolder" method on recycler view adapter. Now problem is that the grid layout views are recreated on every scroll. I don't want those views to be recreated on scroll. How to deal with it?? Here is the code snippet @Override public void onBindViewHolder(final PersonViewHolder personViewHolder, final int i) { GridLayout feedGrid = new

How do I set android:layout_columnWeight=“1” programmatically to an element in an android support v7 Gridlayout

泪湿孤枕 提交于 2019-12-21 06:47:09
问题 I'm trying to build a GirdLayout programmatically with 2 columns and I want these columns to have equal width set at half the width of the screen. I figured out you can do this since API 21 or with the support v7 GirdLayout view. I see examples that uses android:layout_columnWeight="1" to do this. But I can not find how to do this programmatically. Can anyone help me with this matter? package com.tunify.v3.component; import java.util.ArrayList; import android.support.v7.widget.GridLayout;

How to use layout weight in GridLayout for APIs lower than 21

爷,独闯天下 提交于 2019-12-21 02:35:10
问题 I want to evenly spread 8 buttons using GridLayout . I want to support the APIs lower than 21 (which is the minimum number that supports layout_columnWeight and layout_rowWeight in GridLayout ) Here's my code <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin

Trying to replicate GridLayout column alignment with ConstraintLayout

為{幸葍}努か 提交于 2019-12-20 17:31:57
问题 I'm new to ConstraintLayout, and I'm trying to replicate the same grid behavior offered by GridLayout with ConstraintLayout. Specifically, I want to design a two columns grid. The first column width should be as narrow as possible, while the second column should take all the remaining horizontal space. Of course, the second column should be just to the right of the first column, or rather, to the widest view on the first column. I don't know how can I replicate this last requirement with

Trying to replicate GridLayout column alignment with ConstraintLayout

丶灬走出姿态 提交于 2019-12-20 17:31:43
问题 I'm new to ConstraintLayout, and I'm trying to replicate the same grid behavior offered by GridLayout with ConstraintLayout. Specifically, I want to design a two columns grid. The first column width should be as narrow as possible, while the second column should take all the remaining horizontal space. Of course, the second column should be just to the right of the first column, or rather, to the widest view on the first column. I don't know how can I replicate this last requirement with

Android: Create grid with dynamic size in gridlayout or gridview

时光毁灭记忆、已成空白 提交于 2019-12-19 03:18:50
问题 I am planning to make grid base application in which number of grids will change according to user's click. grid pattern:- 2*2 , 4*4 ... [like, user will click on correct grid then number of grid will increase]. I cn able to make grid but it is not fit in layout. so, how can i change the number of grid on user's click and how can i set size of grid dynamically. Here i have attached the image which i want to achieve . When user click on different color grid , Number of grid will increase like

Textview with long text pushes out other views in GridLayout despite ellipsize=end

久未见 提交于 2019-12-18 10:34:15
问题 My problem is very similar to How to get a layout where one text can grow and ellipsize, but not gobble up the other elements on the layout, but read on below why I can't use TableLayouts as proposed there. I'm trying to create a listview row that basically looks like this: | TextView | View 1 | View 2 | All views contain variable width elements. The TextView has ellipsize="end" set. View 1 should align left of the TextView, while View 2 should align to the right of the screen. So, normally,

How can i get Vertical scrolling in GridView android?

半世苍凉 提交于 2019-12-18 08:47:11
问题 I am developing an android application with showing images. I am using grid view to show the images in my application. But default gridview is horizontal scrolling I want to show the images in vertical scrolling grid view. Please suggest me a way to achieve vertical scrolling in gridview. Thanks in advance. 回答1: Use android:numColumns="3" // this will force gridview to have 3 columns and if you have more than 3 items in grid view, you can have vertical scrolling. Ex.: <GridView xmlns:android=

View disappears after setting height of gridLayout to wrap_content

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 17:08:41
问题 I have a list view. The layout for each row is: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" app:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingRight="16dp" android:paddingLeft="16dp" app:columnCount="4"> <View android:layout_width="3dp" android:layout_height="wrap_content" app:layout_row=

How to use GridLayout.Spec for a column extending multiple rows?

谁说胖子不能爱 提交于 2019-12-13 14:22:47
问题 I'm trying to dynamically create a table with 2 rows and 4 columns. But the size of rows and columns in each case should not be the same. Perhaps I will attach a picture: I would like: As I understand, when i don't use XML markup to achieve this using a GridLayout.Spec in setLayoutParams But I don't understand what parameters I need to pass in GridLayout.Spec ? If I want to merge the first column in the first row with the first column of the second row, what should I specify in GridLayout