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 :)
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'm building a tablet Android app with a scrolling mosaic with tiles of various sizes (3x2, 1x1, 1x2, etc.), similar to the image above.
I'm building the horizontally-scrolling view in "blocks of 15", using multiple 5x3 GridLayouts.
My problem is that while I'm able to get the correct number of total cells to fill each GridLayout block, unless I get lucky with the ordering of the tiles, I'm inevitably left with gaps with empty cells and a couple 1x1s rendered off screen.
Is there a strategy for ordering the insertion of tiles to ensure each block of 15 has every cell filled? Or a way to inspect a GridLayout after the fact to manually fill any empty cells?
I would rather suggest you to have a look at the apps like "launcher8" https://play.google.com/store/apps/details?id=com.lx.launcher8
This app has the same kind of UI you need,
....and open the DDMS view in eclipse and use the hierarchy viewer to see the layout hierarchy and so you can get the hint to create a view hierarchy like this.
steps
first open devices in ddms view of eclipse
then click on hierarchy viewer to capture the layout.
after this you will get a screen just as your phone is displaying at that point,just hover over any area to see the complete hierarchy of it.
*
conclusion
You will see the layout hierarchy on your right as you can see that it uses no grid view it just uses a combination of linearlayout framelayout.
*
hope it helps you.
I am newbi in android world and working on an android app.
I have used many of buttons and image buttons in my app.
Now i want to replace them with an background image. (So i can make nice gui easily)
I know i can use view listener and i can find the clicked x and y coordinate from onclick method.
But I want to how can i find which part of the image was clicked. Because different phones have different resolutions how can i do this efficiently ?
And one more thing, Is it good to handle gui this way ?
Thanks !
You first need to set the initial window width and height before execution of other code and load an image of quality based on the screen size. so for example you can have 3 sets of images of different size. One for 5 inch screens and below. Another for 7 inch tablets. Another for 10 and possibly another super high quality image for anything above. As many devices coming on in the near future are reaching resolutions much higher then previously developed for. Just run code initially that detects the initial window size at hand and load image based on resolution of that device. From their program as you plan to.
Also to jump on answer above. Detect rotation event and adjust image accordingly. and update accordingly. You are adding more programming of course but no reason what you are asking could not be done. Just a few extra events detection and you should be good to go to accomplish exactly what you are looking to do
AFAIK it is not good practice to handle the GUI this way. Mostly because android screen size is not standard and so you can never be sure that it will work perfectly in all the devices. You can ofcourse handle the events using onTouchListener and see which part of image was clicked from the coordinates in the MotionEvent Object. But, I would not recommend doing so.
Creating layouts of different screen sizes and handling the events using Buttons and ImageButtons will be good.
you can use android:background attribute for background images in the layout xml files...
however you also can set the background of UI element programatically
How can I create drag and drop graphics in Android almost similar to html5's canvas. Specifically I want to mimic how ancestry.com's android app "family tree" screen is in the picture below. I want to be able to drag/drop the nodes and connect/disconnect them. I also want the screen to seem "endless"; if you've used ancestry.com's android app you will notice that in this screen below you can move the entire tree left/right until no more nodes are left. My guess is that the nodes in these screens are image buttons and they use some type of horizontal scroll view, but I'm not sure. Thanks for your help in advance! :)
I am an experienced developer, but I'm inexperienced on the Android platform. So I am seeking some advice from developers with more experience with Android.
I am building a Honeycomb application using Fragments. One of the fragments calls for a vertically scroll-able read-only "HTML table-like" view with dynamically loaded data. Similar to a spreadsheet, I should have clickable headers which I can implement server-side requests to filter/sort the data.
I am pretty sure this Control doesn't exist yet, am I right? Do I have to build it?
Assuming I have to build it, which existing widget should I extend? ListView, Table, GridView?
I assume I would have one widget for the header, and then wrap the body of the table in a scrollable layout to handle scrolling while keeping the header visible. I am concerned that I might not be able to guarantee that the headers line up with the columns.
Thanks in advance,
Tim
Android layouts are pretty basic - there are not any shipped layouts that will really do what you are looking for automatically, but you could probably do what you want with a heavily controlled gridView. Android is also pretty bad about controlling multiple elements to fit within the screen size, as it's goal is to support multiple screen sizes and densities.
From what I understand your desire to be, I think the best solution is to create a nx2 grid view dynamically, and control the width of the view based on the device size. You would have n number of headers on the top, and you could fill the lower half of the grid with your textViews, or whatever data you wanted. The hard part would be keeping the widths of the grid elements under control and on the screen. In addition, you will probably find that you can only fit a small number of header items on the screen because of the phone's small size, so you may discover a better layout to fit your needs.