Jul 10, 2010
I want to change how a gallery looks like. I want to add 2 jogs at each side, so looks like this:
View 7 Replies
First approach was to add the "jogs" to the ImageAdapter (at the beginning and at the end) for the Gallery. The Gallery will show the items as usual, but It will apply the custom background and also if you specify spacing, you will get an ugly gallery. Also, I want the jog not to be centered as the others images. Then, I decided to download the whole api and modify the Gallery source in a way so to handle specially the first item and the last item of the adapter. But, I don't know how to compile the api alone. The Makefile in the root project will build 6gb of the whole android platform. If someone can explain me how to build just the API, I will be grateful.
The other approach was to compose Views. I thought to add ImageView's to the left and right corner and to be scrolled when needed, but when the Gallery capture the events I can't forward it to the holder of the ImageViews. So, I extend Gallery, and I override onScroll() like this:
super.onScroll(e1,e2,distanceX,distanceY); return false;
and also onTouchEvent() like this:
super.onTouchEvent(event); return false;
But unfortunately when I return false wihtin onTouchEvent() the Gallery does not scroll.
So, main questions are:
1) How can I compile the modified API to generete a MyGallery.class to be added to android.jar? If I modify the source code of Gallery.java I can manage the fill of the Gallery for the specific items I want (I already read the source code).
2) In other approach, Is it possible to handle one event by 2 widgets? If so, I could overlap the Gallery above a jog. The Gallery will scroll as he knows, and I will scroll as I want.
3) If those approachs are bad, what will you recommend ?
I don't get why the Gallery does not have this nice feature I want to implement, kind of: setBorders(left, right) and etc. The problem on extending Gallery, is that when you add a View (for instance, the "jog"), you specify a position. Gallery fills the gallery getting the Views of it container with: getChildAt(0) and getChildAt(numChildren -1) when filling to right and left, respectively. Then, it gathers the 'unseen' Views from the Adapter. So the added view (the 'jog') will be scrolled by Gallery, but when the view is no longer visible, the Gallery itself has no way to get back that view, as it's not in the Adapter.