I need to create large table with horizontal and vertical scrolling. Each cell of this table should be clickable.
To make it clear this is a picture of what I am trying to achieve. Scrollable area on the center, empty cells and cells with numbers should be clickable.
I've tried different approaches, but all end up failed:
GridView:
Problem: gridview elements are clickable and scrollable, but scroll is only vertical.
HorizontalScrollView is placed in VerticalScrollView, while LinearLayout, which represents a table row, is placed in HorizontalScrollView. And program built table adds new Linearlayouts row by row. Scrolling is implemented manually in a parent layout by setting coordinates to scroll views in TouchEvent. I'm using custom ScrollViews which return false in ontouchevent to set coordinates in parent. Scrolling works fine, but when we attach onClickEvent to a cell(textview), it breaks. Clicking works, but scrolling doesn't. I've tried different modifications (onintercepttouchevent) of this approach, but best result was scroll causing click after scrolling.
Also table header should be fixed vertically.
The first and last column should be fixed horizontally.
I wonder how Google made this in Google Docs app. Their table is perfectly scrollable and clickable.
I found working solutuion. Instead of OnTouchEvent I use onScrollChanged and onHorizontalScrollChanged for manual scroll. With this approach clicking works fine but doesn't work diagonal scroll, because event parameter x is always 0 in onScrollChanged(and opposite in onHorizontalScrollChanged).
Related
I want to develop an app that includes GridView and I want it to be some thing like horizontal ListView above a gridvew .Horizontal view displays images downloaded from url.I saw this touturial ( horizontal scrollview used)
and saw this to put the GridView inside scrollView because i want to put the gridview(episode #2) and horizontal view (episode #1) in vertical scrollview(episode #3) . I need to scroll the horizontal view vertically when a user is scrolling the gridview and not to have fixed position at the top of the screen.
I have no idea how to do this (use horizontal ScrollView or horizontal Listview)?
after vertical scrolling I want it to be like this (horizontal view must get scrolled vertically):
This is a custom interaction, so you probably will not be able to use a "standard" tool for this. You may want something like the FloatingActionButton (an example here: http://antonioleiva.com/collapsing-toolbar-layout/) but you also want it to scroll, so you may need to extend that class.
Also, you could use touch events to do a custom animation on the area, because you will need to track when it is displayed and the direction/distance of the motion event to collapse/expand it. You also would need to know anchors on the list, to determine when it should reappear...
This is a cool design concept, but usually "cool" = "difficult" because it's not standard.
I have a listview and its rows have different heights.
When I scroll up, rows appear to move up or down erratically.
(I don't find the behavior when I scroll down)
I suspect its due to the fact
listView picks one of used rows
the row is placed on top of visible rows.
listView changes the row's height(here erratic movement)
but it's a guess.
I tried googling since this should be a common problem but couldn't find any.
In this case, setting the right item height did the trick :
How to set different heights for each row in a ListView?
Edit: oh, and make sure you recycle the items correctly :
ListView reusing views when ... I don't want it to
I need to do an activity with two "parts". The first one, uses the top half of the screen, and there, I will show some fields (name, date,...). The second one, uses the bottom half of the same screen, and there, I will show a table, with three columns, and with some rows. The quantity of rows is undefined, because they come from a web service.
My doubt is how to do this second part, with a vertical scrollbar table, where the user will see the first half static, and could be able to roler the bottom half to see all rows of the table (like an iframe). I need to use table, because my cells need to be aligned.
I have already tried tablelayout, listview, gridview, and I can't find a way to show the vertical scrollbar.
You could use a ScrollView.
Note though that ScrollView supports one direct child so you may wrap everything up.
You can use something like the following:
MainLayout
TopHalfElements
ScrollView
Linear/relative/frame/whatever layout
Rows From Webservice etc.
You need to have a main layout inside the ScrollView as it only supports one direct child.
I have a LinearLayout containing two ImageViews. The LinearLayout is inside the ScrollView.
When I scroll the screen I would like to know the exact position of the two ImageViews relative to scroll. The getScrollY() doesn't work correctly because the ImageViews continues scrolling after action_up and the value in getScrollY isn't updated in this case. I have this information to disable or enable other elements on screen.
If your 2 views are the same/similar then add them to a ListView, then you can set an OnScrollListener which will tell you when the view is scrolled and the index of the visible item.
When I put a HorizontalScrollView around a GridView, the GridView gets compressed into a small column on the left. The Gridview's vertical scrollbar even appears on the left. The HorizontalScrollView's width is set to fill_parent and the GridView is also fill_parent. I don't know why this is happening.
I tried setting the GridView's visibility to GONE and VISIBILE like someone recommended but it doesn't do anything. However if fastScroll is enabled on the GridView, then dragging the fast scroll tab vertically causes the GridView to expand horizontally and it keeps expanding past the last column.
I understand now why this cannot be done. There should be a way to force the GridView to load all horizontal items and allow horizontal scrolling.
The better choice would be for them to implement some kind of DataGrid control. Most people are under the impression that GridView like a DataGrid.