Advice on Putting Together a Segmented Image - android

I need to put together a complete image, as seen here. Each piece of the segmented tree is an individual image, but I am unsure about how I should put the pieces together efficiently with spacing in between. I've thought about stacking the images on top of each other one at a time within a canvas, but I have my doubts as to whether this is the approach that I should take. Is there a different type of container I should use or a better method of accomplishing the same task?
EDIT: just to clarify, I need to assemble the image programmatically, beginning with the base segment and eventually ending with the top segment.

If you use a program like Gimp, you can added each image as a layer, then move the layers around correctly. I'm not quite sure how you want to represent the space between the segments, transparent?
Any way after you have your image assembled the way you want you can either merge the layers or save it to a format that will flatten out your images.
I'm not sure if you want your image to be able to stretch at all or not. If so, you can save it as a .png file and then use draw9patch or equivalent to add in stretching segments. Also I'm not sure if you have to support multiple drawable sizes, if so I have a free Android app, DP Image Calculator on Google Play that might help. Just remember start with the highest resolution and work you way down to the smallest.
Hope this helps. If you have more question let me know. Have a great day.

Related

Curved Bottom part of Bitmap image Android

Good day guys.I want to make the bottom part of my own image an curved line.Not to talk back and forth here is an image which i want to get into the application.
Important to notice that i have reached 10th result of the google and everything i came up was only some curved image not in my desired way,the whole image was curved and the lines of 4 parts were connected to single one.
So basically i want the image to be as rectangle as it comes from server and only curve the bottom part of a bitmap.Is that even possible?
Noticae the bottom line is curved,that what i want to achieve,and rest parts are rectangle.Thank you for your time.
If you are trying to change the image itself, photoshop or any editing tool is the right way to do it. besides if you are getting the image from a server somewhere then getting the image adjusted from the server, instead of modifying it on the client side(o your app) has lot of benefits.
But, if want to change the look not the image itself, then that could be achieved by creating a custom image view like answered here.
You can also use a card view hold your image view to achieve some curves, although i don't think that would be efficient or satisfactory for your case.
Sometimes, editing the image in Photoshop is the right way. This can save your android app CPU time.

Display images on all android devices

in my android application, I want to display some images of plants (i have more than 100 of them) a i also want to support different screen sizes, but my problem is i can not have images for every screen density in res/drawable folder, because size of my application horribly increase. Is there any solution how to do this? (maybe in code) Thanks a lot.
From what I understand, you want to have the text wrap around the image. You could best achieve this using this library.
As for the images, you would only need to store them at a size that looks good on the largest devices you are looking to support. For the other devices, you would just scale those down. If you're going to use the above library, you might need to set the following parameters on the ImageView in the XML file to have it scale down correctly:
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
Note that you will need to fiddle around with these (especially the weight) so that you get the best fit for your application.
EDIT: To conform to your requirement in the comment, the best way to go would be to use a WebView. This does mean you will need to create HTML code for your articles, which would completely change the question.
What you could try is to have a LinearLayout surrounding the image and add TextView objects to it programatically. There are good chances that this will look bad depending on the amount of text you will be adding.

How to paint colours over a background image?

I've been asked to create an app that allows the user to fill in areas of an image with different colours, very similar to a childs "colour by numbers" game.
I'm not sure how to delineate the areas of the image and make them selectable. Please could someone give me an idea of a good way to go about doing this in Android.
Thanks
It's a kind of a tricky task... There's probably a better way to implement it, but here's my first thought:
You could pre-break the image into separate segments before the app runs.
As far as I know the only type of View you can create is a rectangle. But you can create many small rectangles to fill in parts of your image. Then you can get the clicks on those little areas and make a corresponding segment of your image:
int color= res.getColor(R.color.my_color);
image.setColorFilter(color, Mode.SRC_ATOP);
Hope this helps!
If you don't mind writing some NDK code, you could try OpenCV's cvFloodFill method. Otherwise you have to implement one of the image segmentation methods.

How to create a Raining Effect(Particles) on Android?

I am developing a 2d android strategy game, it runs on SurfaceView, so I can't(or can I?) use LibGdx's particle system. And I would like to make a raining effect, I am aiming for something like this( http://ridingwiththeriver.files.wordpress.com/2010/09/rain-fall-animation.gif ), I don't need the splash effect in the end (although that would be superb, but probably would take up a lot of system resources). How could I achieve that raining effect? Any ideas?
There's one similar code from JakeWharton called DroidFlake. It seem like snowfall effect but worthy to check DroidFlake
The easiest would be to put the rain drops in a PNG with alpha and display that at the end. You would only need a few frames to make it smooth, but it would eat up a bit of resources if this were a full screen image.
If you cannot afford this, you could put each distinct raindrop in a smaller PNG file with alpha, then display this (these) single PNG(s) multiple times. This would reduce the memory used a lot, although your rendering code will get a bit more complex, and depending on how many drops you have, it might affect performance.
A trade-off between the two would be to have a PNG file that contains more drops, but not for the full screen, and display that a few times.
You could have another frame (or frames) where the raindrop splashed, which you could display before ending the animation of each drop, or you could have the final frame in the large PNG contain the splashes.
There are many ways of doing this. You could create a sprite sheet like:
In that spritesheet, you could simply have a drop of water advance in each frame until it reaches the bottom and you create the splash effect. You then need to be able to animate it (very easy). You can then create multiple instances of the image, or draw the one image multiple times to create the rain storm.

Should I draw or load an image?

I am wondering what would be the best practice for android. To draw or to load an image?
For example I want to have a circle that is green filled with the text 25 in it.
-Should I have it in .PNG image file and just load it to the imageview placeholder when I need it?
OR should I load it in Java (by determining the position in java and load it from my res folder)?
OR Should I draw it (draw a circle, fill color, add text field inside)?
On another note, to have a checkmark, what do advise me to do?I don't even know how to draw that
I really need your help in this
Thank you so much
I'd actually argue that there is a single right answer. You should use a shape with a set color and text view inside it. It is easy to do what you've described in xml, see: Oval Gradient in Android for an example (there are a number if you google for android shapes). This will be less CPU/memory intensive than loading a bitmap, and more importantly, it will work for and look good on every screen size. As an added bonus of the user has changed their default font sizes, a textView/shape can respect that and a static image can not. Just set the background of your TextView to be the shape drawable (either in xml or programatically).
To get a bitmap to look good on multiple devices (a must for android development) , you will need a number of different versions of the same bitmap at different resolutions (XHDPI, HDPI, MDPI... etc).
Check marks are harder because they don't conform to a standard shape. Those you probably will have to make pngs for.
It depends on what you want to do.
Rendering a bitmap will be faster, but you cannot manipulate it after it is drawn.
So, for your case, you have a green circle with 25 written it. Do you also need a green ball with 23 and another with 24 in it? What about other colors?
It really depends on the amount of variation you need. At a certain point the overhead of using dozens of images will not be worth the evert of drawing to a canvas. Or, depending on how complex the images are, it will be.
The question is not "Which is better?", but instead, "Which is better for what I need to do?"
I'm not an expert on Android development but after seeing your question I have done a bit of reading and came across this article on displaying images with android that is relevant and includes some code to possibly help you out. http://www.javacodegeeks.com/2011/07/android-game-development-displaying.html
As for your image of a check mark, why dont you just go into photoshop or paint and use the line tool to draw a checkmark and then fill it in with color and save it as a .png perhaps?

Categories

Resources