Android: Horizontal list view on custom adaptor - android

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

Related

Horizontalscroll view UI breakdown

I am trying to make a horizontal scroll just like the one showed image below, I have a horizontal scroll view here but how is it focusing on a single item in list when I scroll(I am asking about the sort of forward effect of middle one)
Thanks!
Her's the link which may help you https://github.com/blessenm/AndroidAutoScrollListView

Custom GridView's Last row items not showing fully

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.

What is the best way to implement Header support in GridView?

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.

Multi column listview layout

How to do a layout like this? I currently use a listActivity and I need the same experience with this kind of layout.
You can use Staggered Grid View library. Also check and Quilt View. This is what you need.
To get this effect, you should create two list views and link the scrolls of both lists.
Define a OnScrollListener on both listviews and when "onScroll()", move programatically the other list. I think if all images are cached you shouldn't have delays.
You can use Staggered Grid View library. But there you need to mention height of each image pragmatically to set height of list view. Else when you scroll to end and come back to top, the alignment of images on top will get disturbed
You have to use GridView
You can refer this or this.

Horizontal Carousel or ScrollView with text over image

I'm trying to figure out the best approach to design a horizontal scrollview from android >= 2.1 with some text over the image that when scroll if end is reached it starts showing the first items again hence carousel behavior.
You can continue scrolling horizontally, forever, and the first item shows up again when the end is reached, for example when scrolling swiping to the left. It can be a view pager with an adapter, a carousel but not horizontal scrollview as it does not support some android device.
Any suggestions would be greatly appreciated.
Why not use a ViewPager? As it is available in the Support Library. I would insist to use ViewPager instead of HorizontalScrollView or Gallery. You can check an example for ViewPager from my github.
UPDATE
To show multiple views inside a Fragment you can use getPageWidth(). Check here for reference.
For future people looking for this, here's an excellent library that fit my needs for a similar problem!
https://github.com/sparrow007/CarouselRecyclerview

Categories

Resources