I need to implement a list of images and buttons. I have 6 images serving as separators and a total 14 buttons with custom background. The list has a full screen (800×600) background, the separator images are 800×30 pixels and the buttons have similar size as well (all buttons have the same background image). On top of this, I need a custom scroll indicator: two blinking arrows on top and bottom. The arrows should be shown or hidden according to the scroll position.
I have some other GUI elements including a GLSurfaceView hidden using View.GONE as the list is shown on top of those.
The problem is, that this setup runs too slow on relatively powerful handsets such as the Galaxy Nexus or the Desire HD.
I tried two different approaches:
Using a ListView based on this tutorial: http://android.amberfog.com/?p=296
Put all buttons and images into one LinearLayout and use that as a child of a ScrollView. To hide and show the the blinking arrows I determine scroll position by overriding onScrollChanged (Synchronise ScrollView scroll positions - android)
Both implementation runs slow depending on the actual handset. The ScrollView implementation is usually faster but it has noticable lags on a Desire or the Galaxy Nexus while the ListView implementation is slow on the Desire HD.
Which is the best way to implement such list? Could you suggest me some guidelines how to make the implementation fast and device independent? I believe having about 20 images and buttons in a list shouldn't be a problem for these handsets.
Ok, it seems that the problem was the following:
I had a GLSurfaceView in the same activity and the list appeared above it. This was too much for the UI thread, although the list totally overlapped the GLSurfaceView and the rendering was paused when the list appeared.
I moved the list to a different activity and now it has an acceptable speed. But switching to the list is slower and when I close the list, I have to reload the surfaceview, but that is ok.
Related
We want to show in an Android app a list of images in the similar manner with many gallery apps: horizontal sliding by using a gesture to show the next/previous image.
Also the image viewer should support zoom/pinch (besides other features).
Images can came from a database or from a directory and can be as much as 200-300.
The question is: Which is the best way to implement the slide-show part from the environment described above?
Through animations of a two TImage? There exist a specialized component for this? By using Horizontal Scroll box?
Stick 10 TRectangle objects in a THorzScrollBox. It could be more or less than 10 depending on the memory that the device has. Align them all to alTop. Load the images for display in TRectangle.Fill.Bitmap.Bitmap.
When the user scrolls down and is near the bottom of the ten, move the top rectangle to the bottom of the chain and load the newest image from your list into the new bottom one.
When the user scrolls up and is near the top of the ten, move the bottom rectangle to the top of the chain and load the newest image from your list into the new top one.
The reason behind doing it this way is that TRectangle is a really light image display container and you are recycling the TRectangle objects instead of deleting and creating them all the time.
It is possible that you will experience a display pop when you move the next TRectangle object to the top of the chain or when you move it to the bottom of the chain. You will have to create code to take care of this either by setting the position on THorzScrollBox or decreasing and increasing the height of the TRectangle as it leaves or enters the view until it is full size.
If you have installed samples with your Delphi instalation then you can find several examples of how to do this in:
Samples\FireMonkey\Fireflow
Samples\FireMonkey\MetropolisUIFlipViewDemo
Maybe there are even more of them. I haven't checked every sample so far.
I want to create a large grid for a android phone application where the size of the grid may vary from e.g. 10x10 to up to around 300x300. The content of each cell will be a test and some background (grid will eventually become skinnable).
I developed this earlier for iOS using UIScrollView and CATextLayers for labels, where the cells' content were loaded/unloaded based on their distance from the the visible section of the screen so that memory-wise it was always within a decent range.
What is the equivalent to this in Android applications?
I will be developing for 2.3 (and later for 4.0) and it should run both on phones and on tablets.
Some info before making a decision:
While in iOS UIScrollView goes in both axis, android's ScrollView just go in one direction.
In Android you have a GridView, but, once again, I don't think you can scroll in both axis.
In Android, widgets that work like a UITableView needs an Adapter that takes care of creating each of the views.
If I were you I would start reading:
How androidbigimage project handles the scrolling through all the screen.
How the GridView positions it's item in a grid and how it handles the variation of the grid size.
Once you get all that info, create a custom view similar to the GridView and start placing items using an Adapter.
PS: When you finish it, make it open source :)
So I have multiple very long images (like 2000x100) that i want to have scrolling across the screen at different speeds. and my original solution is not working out. Originally, I placed them all in a HorizontalScrollView, and made a runnable that used setPadding to adjust the position of the ImageViews within the scrollView. This works, however, the background that is supposed to remain mostly stationary on the screen, shakes back and forth as you scroll, and lags behind the scroll location significantly. It's choppy and it looks bad.
Is there any other way that I can move images across the screen to achieve the desired effect?
(could I perhaps use a frame layout, and set an ontouchlistener? then how would you move the layout across the screen?)
I set up a layout so that the images protrude off of the right of the screen correctly, but I can't seem to move them off of the left of the screen (setpadding(-50,0,0,0) does not work)
Thanks in advance!
I solved this by using relative layouts within a frame layout. I set an ontouchlistener for the frame layout and used the scrollTo method for each image with a modifying coefficient. I had not previously noticed the scrollTo and scrollBy methods of the layout.
I need to display some images which can be scrolled horizontally. Only one image should be visible on the screen. It should be like iphone screen, which has multiple 4 or more screen and display the items per screen and shows how many screens left as small circles at the bottom. Like that I have show the small circles as many as the images. I tried GestureListener, but it scroll only a single image. Any suggestions pls..
You might want to take a look at android.widget.AdapterView and android.widget.Gallery: These are standard Android widgets that provide scrolling through images. However, this will not look like the UI you describe (iOS look&feel) but like an Android app...
See this example code:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/Gallery1.html
I am starting a new application and I am willing to use the Dashboard pattern.
For example: The Google IO app uses it:
My issue is that the amount of buttons will be more than six.
I'm not sure if I should use vertical or horizontal scrolling.
Vertical scrolling could be done with a ScrollView or a GridView but I am not sure which would be the easier way to implement the horizontal version.
I was thinking of using an HorizontalScrollView but it doesn't have pagination. It should feel similar to the tweetdeck app.
How would you implement it?
My issue is that the amount of buttons will be more than six. I'm not sure if I should use vertical or horizontal scrolling.
IMHO, do neither. Reduce the number of buttons. Watch the 2010 Google I|O presentation on this design pattern -- the point behind the dashboard is to only surface a few items.
I would go with a vertical scroll. It is way more natural to scroll down to view more content of the same view.
A horizontal scroll kind of feels like you switch to another part of the application.
I have an app that uses a gridview with vertical scrolling but I dynamically adjust the number of rows in the gridview based on the width of the actual screen so that it in landscape or in a bigger display it uses more columns and avoid scrolling alltogether in most cases.
However in my case it is more of a search results display of categories and not a dashboard. I believe the whole point of a dashboard is to have only a small number of button (e.g. max six or so).
What you could do is dynamically interrogate the screen real estate and if there is not enough room just show e.g. 6 buttons of which one is a more/utils or whatever button. Sort of like the options menu does it.. but on a bigger screen display them all.
It would be interesting to scroll based on the orientation of the device, so you would scroll horizontally or vertically if the device is oriented that way. This would let you maximize the screen real estate.