draw line and caption in imageview canvas - android

Hi I want to draw line and text to an human image for captioning each part of a human body.
I have imageview in android to show human body, can anyone give me a idea to do this.

Yep, it is simple.
Over the ImageView add a Linear Layout, and you have to place in that weightSum = 3 ( head, arms, legs), this way you are making a childs that covers those areas.
Also for example the hands, divide the child in 3 more childs like, so the one on the left is covering the left arm, the one in the middle is covering the body, and on the = right child the right arm. And after that place in them the TextView according to the body part.
I did this for a TV Remote, and it worked perfect.

Related

How can I make an android layout with four quadrants and a circle in between

I'm trying to design a layout with four divided columns and a circle in the center something like the image in the link below. Any help would be appreciated
A simpler approach would be to design the columns and circle is a single png, and then just show it as a background of the layout and the place the TextView in the desired order of your choosing , and as for the center textView put it inside a Constraint Layout and then center it.
This is how you want it to be, and it can be done like this
You can easily these in Photoshop or whatever tool suits you
On and yess keep in mind that i just moved the column 1px outwards in the respective way so as to create that central divider look since adding individual border to each columns inward side would be more hectic, and this way you just have to move the columns outward (if you move then up remember to move them to left/right respectively or if you move them bottom do the same and move the left/right so as to have them in perfect sync.
Another Method
Another method would be to us each piece of this design individually and them use them as the backgrounds for each TextView or have them as the background for each RelativeLayout 's background and have them as Parent to each TextView.
And As For the Image of the Jersey You place it dynamically in the Relativelayout of the inner Circle.
I hope this helps.

Android layout vs. custom view

I want to generate the following for my Android application.
I tried to achieve this using RelativeLayout and some drawables (empty circle, filled circle, dotted line) I created using XML , but I am not even close to it. Is it the right way to generate such views with layouts. If so, is RelativeLayout is the way to go? Or should I create a custom view for that?
why are there 4 dots between the last item and the one before it, while the other have 3 dots?
anyway, i think you can achieve those results by having a listView with custom items.
each item would be shown as a relativeLayout with 2 imageViews (one below the other) and a textView on the right of the upper one.
the upper imageView would have the large dot (filled or not), with optional dots above it, and the imageView below would stretch its size according to the textView (align to its bottom plus add some more for extra small-dots) and have tiled dots as its background.
another approach would be to have a listView of textViews and an imageView on its left, and you draw the circles according to what the listView is currently showing (even while scrolling). it's much harder, but might be more precise.

Android: creating custom 2D avatar

I am creating an app that allows a user to build a custom 2D avatar by specifying things like shoes, socks, skin color, etc...
Currently my solution has been to create a .PNG of each item and then to 'stack' them all on top of each other in a RelativeLayout. So for example, I create an ImageView of two shoes and align the ImageView to the center of the relative layout and the bottom of the Relative Layout. Next I 'stack' the bottom edge of the socks to the top edge of the shoe. And on and on.
This method works, but I feel like I don't have much control over where the parts sit and would much rather be able to calculate the x,y coordinates at run time and place the images that way. For instance, this works well if all of the ImageViews are stacked, but if I need to place one ImageView 10 pixels below the top edge of another ImageView I can't do it (or at least I haven't figured out how yet).
I am looking for a solution that will allow me to control the x,y position of ImageViews and allow ImageView to be offset from each other.
If you'd rather place the images by x,y coordinates, then you should consider using a single view and simply drawing the images on top. See this doc on custom drawing. You'll find drawBitmap and some of its overloads useful.

Android clip upper part of text in TextView

I need to have two TextViews displaying same number, first of which should display upper half and second lower half in order to animate those parts differently. (See images below, there's an example with '8' digit).
http://img403.imageshack.us/img403/2461/bottomtop.png
While clipping bottom is perfectly simple (setting TextView's height is just enough), the second task I find very hard. The only solution I came up with till now is to wrap TextView into some layout and set it's y position to negative - it would be OK, but I need to care about optimization because there will be many digits animated in that way simultaneously.
Do any of you know how to achieve this in more effective way?
What about overlaying the top textview OVER the bottom textview (maybe with the white spacer as well?

How to create a button that consists of three image (Android) so that mid image is tiled?

In short, I need a button that would consist of three images: left, mid and right so that depending of button text length, the mid image would be tiled.
Can someone please tell me (or provide some links) what is the fastest (maybe not the best) to get something like this?
I had to make a button using some compound images, text and backgrounds. The fastest way I found was to make a RelativeLayout with the elements I needed arranged how I wanted, tiled gradient, icons etc. Then apply a click listener to the RelativeLayout and treat it like any other Button in the code.
i'm not sure i read it right you want i to tile the mid image..
but out of my head.. which i have not tried. here is what i will try first.
button.setBackground..
button.setCompoundDrawables(left, top, right, bottom)
if you can make a tile-able background xml and set it as background. then you can try playing around the compound drawables.

Categories

Resources