android-gridlayout

Android Button in Gridlayout don't have same margin top

放肆的年华 提交于 2019-12-11 10:19:50
问题 I got a GridLayout, and there will be two or more buttons in the layout, and all the buttons must with same width. My problem is that when the buttons having different line number of text, the marginTop of button will different too. How can I fix this? Thanks. <GridLayout android:id="@+id/grid_buddies" android:columnCount="4" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="60dp" android:layout_height="match_parent" android:text="TEST"/>

View fills all the available space

狂风中的少年 提交于 2019-12-11 09:04:54
问题 I am trying to use GridLayout programmatically. Here is my code: GridLayout p = new GridLayout(this); p.setRowCount(20); p.setColumnCount(20); View c = new View(this); c.setBackgroundColor(this.getResources().getColor(R.color.darkbluetheme)); Spec specusata = android.support.v7.widget.GridLayout.spec(1,2); Spec specusata2 = android.support.v7.widget.GridLayout.spec(1,2); p.addView(c,new LayoutParams(specusata,specusata2)); setContentView(p); Here is the result I get: While i was expecting

Resize imageViews in a grid layout

北战南征 提交于 2019-12-11 05:05:47
问题 I'm trying to create a Tria games in android. I have created a grid layout with 3 rows and 3 columns. Inside the cells there 9 square imageViews. I want occupy all the space of the grid layout, and the images must have the same dimensions. How can I do this? There is the layout <GridLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:columnCount="3" android:rowCount="3"> and this is a sample of an imageView <ImageView android:id="@

Place items from right to left in gridLayout

丶灬走出姿态 提交于 2019-12-11 03:08:28
问题 I have a GridLayout in one of my layouts. I want to place items from right to left, Which means I want to have cell(1,1) in top right of my layout. I have tested these codes in GridView so far: 1- android:gravity="right" and android:layout_gravity="right" but it doesn't work. 2- I also tested android:layoutDirection="rtl" and it doesn't work too. how can I place items from right to left? 回答1: Here is a workaround add this line to your GridView in XML: android:rotationY="180" then add the same

Use of GridLayout from support library leads to 'NoSuchMethodError: android.support.v4.view.ViewCompat.getLayoutDirection'

馋奶兔 提交于 2019-12-10 17:11:31
问题 I am using GridLayout in my app and it works perfectly. Now I have to support android 3.xx as well, so I included android-support-library-v7. I just changed the import statements for GridLayout and LayoutParams at all places. I can build the project now but when I run the app, it crashes with NoSuchMethodError exception. I followed these steps to include the support library Here is the stacktrace: 03-27 13:37:13.454: E/AndroidRuntime(23016): FATAL EXCEPTION: main 03-27 13:37:13.454: E

GridLayout column is going beyond its bounds

不羁的心 提交于 2019-12-09 17:21:51
问题 I'm trying to make a grid-like form, similar to the example on the official Android Developers blog. Here is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <GridLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="48dp" android:layout_marginRight="48dp" android

How to add elements to a GridLayout dynamically with different column widths for every row based on element size? [duplicate]

前提是你 提交于 2019-12-07 22:27:45
问题 This question already has answers here : Android GridLayout with dynamic number of columns per row (2 answers) Closed 7 months ago . I have a variable-size array of tags that I want to show inside a gridlayout . The problem is that the tags vary in length and it looks kind of messy to put them inside a statically defined grid even when some tags are much bigger than others. So I would like to be able to put tag after tag until there is no more space left for a full tag and then go to the next

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

时光总嘲笑我的痴心妄想 提交于 2019-12-07 04:57:00
问题 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

How to add elements to a GridLayout dynamically with different column widths for every row based on element size? [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-06 15:04:41
This question already has answers here : Android GridLayout with dynamic number of columns per row (2 answers) Closed 7 months ago . I have a variable-size array of tags that I want to show inside a gridlayout . The problem is that the tags vary in length and it looks kind of messy to put them inside a statically defined grid even when some tags are much bigger than others. So I would like to be able to put tag after tag until there is no more space left for a full tag and then go to the next row. Basically something like this: | *** ****** ****** ** ***** | | ** ***** *** ********* *** | | **

Issues adding child to GridLayout dynamically in android

时光总嘲笑我的痴心妄想 提交于 2019-12-06 05:07:51
问题 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