Android GridView 1 full width item then 2 columns, how? - java

I need the first item in my GridView to be twice the size of other items, then all next items to be same size which is half the first item size.
using GridView is not mandatory, it just seems to me it should be done using GridView.

You can put the first item out of the gridview in a RelativeLayout
it is not an elegant solution, but it's a solution

You should go with GridLayout :-
here is a short tutorial http://developer.samsung.com/android/technical-docs/GridLayout-in-Android
custom arrangement in GridLayout :- Heterogeneous GridLayout

You can use a linearlayout, set layout_width of all items to 0dp, set layout_weight of the first to 2 and layout_weight of the others to 1

Related

Android GridView populate from the bottom

I'm using a GridView, and I want items in the grid to start from bottom left and grow to top. Any suggestions on how I can achieve that?
I tried using this attribute:
android:stackFromBottom="true"
but it doesn't work! What can be done?
I am not sure about GridView,
but in a GridLayout when you set its orientation to vertical. each new view is added vertically.
row count limits the number of views per column.

How to always show full items not part of items in Recyclerview?

I'm new to android development
I have a Recyclerview and I want it to always show items with full layout not part of the item when screen size is changed!
say I have a Recyclerview that shows 3 items vertically in XXXhdpi when I changed the device with smaller screen (for example the new device's screen size is XXhdpi) the recyclerview shows 2 items and part of the 3rd Item and you have to scroll to see the whole item...
how to avoid this problem and always show the 3 items or maybe 2 items ! what i care about is to always show the whole item that fits in the screen not part of it.
if the screen can fit 2 items then the 3rd item should not be showed and the 2 items that appear should have bigger width and height to fit in the screen and hide the space of the 3rd item.
Thank you.
Let's say single_row.xml is the layout that is repeated in the recylcerview
You will have to create separate single_row.xml layouts for various screen sizes. And they will be accordingly used during the onCreateViewHolder

How to make a linear layout expand on tap showing less colapsed

If I have a linear layout with vertical orientation and e.g. 6 children layouts what is the standard way to make it into a tappable layout?
I.e. Show only 2 of the children and on tap expand to show all?
I can think of having 2 layouts one with 2 children and 1 with 6 and hide/show each one alternatively on tap.
Is there a more standard way?
Standard way to do it by using Expandable ListView.
You can find a working example here
It look like this

Can't click Field in GridView which has own GridView

I had adapter for GridView which has 2 ImageView and 2 TextView.
I setOnItemClickListener this GridView and it worked great.
I wanted add to this adapter another GridView(which has another adapter(with TextView and ImageView).
So, every field in main GridView has images, texts and small GridView. I can click "large" fields when small GridView is empty. When I add something to this small GridView it looks like I wanted but then I can't click "Large" fields, only these "small".
I tried to setFocusable, Clicable etc. to false but I can still click only "small" fields.
How can I fix this?
Surprisingly, it's working when I add:
holder.internalGrid.setFocusable(false);
holder.internalGrid.setFocusableInTouchMode(false);
in outer GridView adapter. I don't know why that does not work when I put this in xml.

How to disable scrolling for ListView on Android?

I have the following question: I have a difficult layout that contain ListView. I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. I need that if ListView has 10 items that all items will be shown. How can I do it?
Can't you just use a LinearLayout with 10 elements instead of the ListView? It is not a good idea to have a ScrollView in another ScrollView.
Why do you still use the ListView? Create your own Layout for an item and load it several times (LayoutInflater, .addView(listItem)).

Categories