android-gridlayout

How to limit the height of a ListView within a GridLayout?

淺唱寂寞╮ 提交于 2019-12-05 12:11:01
I have a GridLayout containing a ListView and a TextView . When items are added to the ListView it will grow in size and push the TextView below it out of the screen. I thought that by setting layout_gravity="fill" on the ListView it would not grow at all but rather take up all the available space. How do I configure the ListView to take up the available space instead of growing and pushing views below it out of the screen? I am looking for a solution using a GridLayout . I am aware that in my case a LinearLayout would work aswell. However this is just a minimal test case to illustrate my

Programmatically adding TextView to Grid Layout alignment not proper

爷,独闯天下 提交于 2019-12-05 08:13:10
问题 Hi i am trying to add TextView with drawableLeft to GridLayout. I am adding this TextView in an Loop. The TextView are getting added properly but the are not aligned properly. Each textview should take equal width in one horizontal row which is not happening. Following is the code i am using GridLayout gridLayout = new GridLayout(getContext()); gridLayout.setAlignmentMode(GridLayout.ALIGN_BOUNDS); gridLayout.setColumnCount(2); gridLayout.setRowCount(3); TextView titleText; for (int i = 0;

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

送分小仙女□ 提交于 2019-12-04 22:16:30
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; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.ViewGroup; import

Which LayoutManager for the animations of a 2048 game?

a 夏天 提交于 2019-12-04 20:18:00
问题 For training purposes, I am currently replicating the 2048 game. I got the logic and interaction done, but print (and simply refresh) it inside a single TextView which looks ridiculous, of course. When thinking about how to build a UI for the game, I am uncertain which LayoutManager to choose. What I need to be doing in the game's 4 x 4 grid is to merge and add cells inside rows and columns with animation . It seems to me that: GridLayout won't work since it is dealing with the full dataset

GridLayout Column width

核能气质少年 提交于 2019-12-04 14:57:26
问题 I have 2 columns in my GridLayout . What I want to do is make those columns take up half of the width of the screen each and then have its child contents fill their own cells width/height. I tried setting the children to fill_parent but that just causes the first one to take over the entire layout. And it seems GridLayout doesn't support weight ? Maybe there is a better layout to use, but I want a Grid style layout so that seems like the natural choice. 回答1: This code is available on pre

Issues adding child to GridLayout dynamically in android

╄→尐↘猪︶ㄣ 提交于 2019-12-04 09:57:00
I am making a puzzle game. I am trying to make a GridLayout dynamically of size 4x4. I am adding LinearLayout as the child and then an ImageView inside the LinearLayout of the GridLayout through code. Layout is coming perfectly fine. But when I drop an ImageView in any of the grid the image is taking complete height and width of the GridLayout. But it should only take the size of the grid in which it is dropped. Github link of the project. Here is my code: public class PuzzleActivity extends AppCompatActivity { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super

Dynamically change the number of columns of a GridLayoutManager

久未见 提交于 2019-12-03 16:31:53
问题 I am actually using a GridLayoutManager with two columns in my app and I would like to have one column depending on the view type used. Here is the code I have in the method "onCreateView()" of my fragment : // Recycler view for users usersList = (RecyclerView) mView.findViewById(R.id.usersList); // Layout manager (grid of users layoutManager = new GridLayoutManager(mContext, 2); usersList.setLayoutManager(layoutManager); // ArrayList of users users = new ArrayList<User>(); // Set the adapter

Which LayoutManager for the animations of a 2048 game?

那年仲夏 提交于 2019-12-03 12:52:40
For training purposes, I am currently replicating the 2048 game. I got the logic and interaction done, but print (and simply refresh) it inside a single TextView which looks ridiculous, of course. When thinking about how to build a UI for the game, I am uncertain which LayoutManager to choose. What I need to be doing in the game's 4 x 4 grid is to merge and add cells inside rows and columns with animation . It seems to me that: GridLayout won't work since it is dealing with the full dataset (16 tiles in four rows/columns) when I need to be able to deal with single rows and columns. However, I

GridLayout Column width

我是研究僧i 提交于 2019-12-03 09:19:12
I have 2 columns in my GridLayout . What I want to do is make those columns take up half of the width of the screen each and then have its child contents fill their own cells width/height. I tried setting the children to fill_parent but that just causes the first one to take over the entire layout. And it seems GridLayout doesn't support weight ? Maybe there is a better layout to use, but I want a Grid style layout so that seems like the natural choice. Tobliug This code is available on pre API21 with support library! I have a simple piece of code to show 4 buttons in a gridLayout of 2 columns

Android GridLayout Equal Column Widths

非 Y 不嫁゛ 提交于 2019-12-03 08:26:53
问题 Is it really not possible to easily force equal column widths in an Android GridLayout? Trying the obvious layout... <GridLayout 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:columnCount="4" android:rowCount="8" tools:context=".MainActivity" > <Button android:id="@+id/button1" android:layout_gravity="center" android:text="Button 1" /> <Button android:id=