android-gridlayout

Add space to the end of the RecyclerView

烈酒焚心 提交于 2019-12-03 07:27:41
问题 I have a recyclerview with a gridlayout. What I want is when the user scrolls to the end of the list (see my bad mockup), there should be an empty space with a height of 50dp, which isn't the same dimensions as my grid. Note that this space is only visible at the very end end, as I do not want to change the layout. I could make it so that the recycerview has a margin bottom of 50dp, but I do not want to do that. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http:/

Trying to replicate GridLayout column alignment with ConstraintLayout

谁说我不能喝 提交于 2019-12-03 05:55:35
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 ConstraintLayout. I don't want to use a Gridline between the two columns, because the first column should

Changing number of columns with GridLayoutManager and RecyclerView

北城以北 提交于 2019-12-03 01:28:37
问题 Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user rotates the phone/tablet. I've read about onConfigurationChanged and I tried to make it work for my case, but it isn't going in the right way. When I rotate my phone, the app crashes... Could you tell me how to solve this issue? Here is my approach to find the solution, which is not working

How do I call 2 consecutive items in a list in a table form next to each other?

泄露秘密 提交于 2019-12-02 19:31:17
问题 Basically I have a list view containing news headlines such that the first headline covers the top portion, the alternate headline the second portion and third headline third portion and the second and the third are consecutive in the list( the first remains as the only headline in the list ). I have programmatically defined it as follows: public class NewsListAdapter extends UselessAdapter { private static final int NUM_TYPES = 3; LayoutInflater mInflater; private static final class Types {

Changing number of columns with GridLayoutManager and RecyclerView

大憨熊 提交于 2019-12-02 14:50:37
Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user rotates the phone/tablet. I've read about onConfigurationChanged and I tried to make it work for my case, but it isn't going in the right way. When I rotate my phone, the app crashes... Could you tell me how to solve this issue? Here is my approach to find the solution, which is not working correctly: @Override public void onConfigurationChanged(Configuration newConfig) { super

How do I call 2 consecutive items in a list in a table form next to each other?

瘦欲@ 提交于 2019-12-02 12:01:49
Basically I have a list view containing news headlines such that the first headline covers the top portion, the alternate headline the second portion and third headline third portion and the second and the third are consecutive in the list( the first remains as the only headline in the list ). I have programmatically defined it as follows: public class NewsListAdapter extends UselessAdapter { private static final int NUM_TYPES = 3; LayoutInflater mInflater; private static final class Types { public static final int FIRST_HEADLINE = 0; public static final int OTHER_HEADLINE = 1; public static

Long text on button messes up GridLayout rows

本小妞迷上赌 提交于 2019-12-02 05:53:19
问题 I have a GridLayout which is used to host a number of buttons, ordered in two columns. All the buttons have fixed height and width. If one of the buttons contains too much text, the layout is messed up. I'd like for the layout to maintain the rows correctly, regardless of whether buttons have too much text or not (I'll handle the case of displaying too much text later, using auto size of text). This is my code: <GridLayout android:id="@+id/cont_middle" android:layout_width="wrap_content"

how to display 2D array in gridlayout

…衆ロ難τιáo~ 提交于 2019-12-02 05:13:02
I have Array [] [] myArray = new Array [5] [5] , or Array [] [] myArray = new Array [7] [9] , or new Array [12] [13] I want to display the array in GridLayout . I found many examples but there is not a 2D array. Tell me I should extend BaseAdapter ? I do not know about how to solve this problem Simple thing you can do is, you can convert 2D array to a simple 1D array (using a for loop) and proceed as usual. And if you need to set the items dynamically (I mean, if you do not know the dimensions of the array before hand), then you have use the setColumnCount() to set the number of columns you

GridLayout going out of bounds

不羁岁月 提交于 2019-12-02 05:09:29
问题 I am trying to reproduce this calculator layout with the GridLayout but this is what I get with the code I tried. In fact on the device it gets even worse, it cuts even more the last equal button that must span across two rows. <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#000000" android:columnCount="5" android:rowCount="2" android:orientation="horizontal" android:padding=

Android: GridLayout spacing between items

家住魔仙堡 提交于 2019-12-01 15:08:18
I have a grid layout which is filled with buttons, now i want the buttons to be more distant from each other, what code should i write? i tried to search it but only found a solution for GridView, not GridLayout. You can put margin to the buttons Instead of adding margin to each buttons, use android:useDefaultMargins="true" It is better than adding margin to each buttons! 来源: https://stackoverflow.com/questions/35270404/android-gridlayout-spacing-between-items