In My application I have to show all List Items in GridView and then while scroll down the GridView it needed to scroll the upper View(top of GridView) also along with Grid.For this purpose I have used HeaderGridView Add a Header to a GridView (Android). What I needed is working fine but the GridView's last row items are not viewing fully as like attached image.So,anyone please help me to solve this issue.
This is the default property of the gridview. It will show as like that only. If you need it in your own way, then you can solve it only by customizing the gridview by displaying the items in the gridview according to the screen height. This is only just a hint to solve your problem. So Please check this and if you doesn't got solution, please let me know.
Android gridview adjusting to screen size
android How to stretch rows in the gridview to fill screen?
How to make customAdapter fill gridview height
I think this links may give you some guidelines.
Related
I am designing an app like foody, i have 5 item, put it in a gridview and set android:numColumns="3" . but in the second line, the items doesn't appear in center of the gridview row. i have tried some solution but nothing changed. Is anyone here used to deal with it, please give me your solution.
I have to create list of gridview like section gridview where it has title and grid items below, i achieved this by using recyclerview and gridview, but the issue is, scroll doesn't goes smoother, it gives zerk while scrolling. and then i tried with recyclerview, cardview, along with GridLayoutManager, but now i'm not able to set background to the section. please see the attached image, you will get idea on what i am trying.
suggest me which are the best approach to set background without using gridview and listview combination.
I have tried and worked for listview with section view between list items and it works fine for me .
When I tried for gridview it is showing till the each item width not full row because obviously gridview comes with 2 or more items in a row .
So I want to make full row as section item between grid view items .
I searched elsewhere before posting here so can anyone help me ??
I don't think you can do that with GridView widget because it works in terms of columns. You can hack it with adding 3 Views in a row if that will work for you, but it will have obvious drawbacks such as you won't be able to put a text there that will take more that 1/3 of the screen width.
Use RecyclerView vs StaggeredGridLayoutManager instead: http://enoent.fr/blog/2015/01/18/recyclerview-basics/
I am developing an application in which i required horizontal list view with custom adapter. I tried a demo from the Link.
The demo is running fine. But when i implemented the same code in my application the horizontal scroll is not working.
My custom adapter is having the layout whose one item covers whole screen width and around half of the height of the screen.
When i run my code the first item is visible perfectly. But the second item in not visible as the screen is not scrolling. I implemented the same code in same way as given in the link.
Where i am wrong please let me know, or what should i do now please suggest me.
layout whose one item covers whole screen width and around half of the height of the screen
I think you should use a ViewPager for this:
http://developer.android.com/training/animation/screen-slide.html
If you don't like to use Fragments you could try RecyclerView (like jvrodrigues suggested) with a horizontal LinearLayoutManager (available in the support library).
See: https://developer.android.com/training/material/lists-cards.html
hope this helps!
After reading this post, I have implemented my own Horizontal listview. You can find it:link
Everyone knows that GridView does not supports headers and footers like a ListView.
There is a few ways to implementing this:
Use a ListView and form columnt manually via ViewGroups. It not works for me, because it's require a lot of layout operations like measuring and layouting, and it's difficult to implement draw selector on top.
Use special adapter. It works fine with a footer: we should fill last cells with a Space and manually insert after them out footer with width that equals GridView width. But this not works with headers: although header is stretched, next cells float on it.
Use a GridLayout. GridLayout is good, but what about performance with 500-1000 cells? AdapterView supports caching and reusing Views, as far as I know, this is not possible with GridLayout.
Extend GridView and write custom class, that allows to draw a header before the grid content. It's difficult, but it's should work very fast. Let's try to figure out how to do this:
Measure the header. It's very simple, I have not questions about this.
Layout header in the top of the grid. We also should consider with scrolling position to allow move header with whole grid content, so my first question is: how to know where bottom border should be located while scrolling?
Layout whole grid content after the header. How to do that? I've newer do this before.
Dispatch draw to the header view too and resolve overscrolling effect if it's not work well.
Handle the scroll event and refresh header position.
So what you can suggest me? How to do header offset? Is it right to invoke relayouting with every scroll event?
I searched an answer on a same situation with a GridView (but for a FooterView).
I've read attentively your suggestions and some from other websites. I had the same reflexion. I found a simple way as your tip: "Use special adapter. It works fine with a footer..." and this answer by #RaulSoto helped me a lot. But when I tried to update my gridview, I had a NPE, because my footer was not like the layout of my items and I had a custom filter which recalculated the getCount() method, but without understand that another view was added.
Finally, I found only solution which works: a custom class.
Create your own class as you said: "Extend GridView and write custom class" but don't extend GridView. You should extend with ListView and measure the entire width, the column width and the number of columns. I think, it's less difficult that to extend GridView, calculate the height of the header view and move it as you move your gridview or refresh the header each time you handle a scroll event..
I searched to do it in this way and I took this little project on GitHub: HFGridView by Sergey Burish. It was exactly what I need, no more.
I only added a custom attrs file in my app and customize a bit his project to have the expected result (especially, it was to have one column in portrait, two in landscape mode, refering to the numColumns attribute in my layout).
And when I try, just for test, to add a HeaderView and refresh the content with adding new items, the header view stays at the top of my gridview list, without refreshing himself.
So, I think you should search to create your class as GridView extends ListView. Refer you to the HFGridView by SBurish, it is very simple to understand how it does.
Hope this helps you with your purpose.