I have image view with some lines and curves on it. I need to place the text labels into specific locations on this image. How it can be done?
In details:
Look at the image http://s9.postimg.org/63bq7ax4f/e7c5d09764c43a10537ea1b92a0c0c8b.png
I need "92 PAC" and "95 DRI" to be on that line as well as 2 lines below. Now it shifts upside or downside on different screen sizes.
P.S. If it can simplify the problem, the image can be only in one fixed size in one dpi bucket (despite it's incorrect from the android style).
Thank's
Make a custom view. In your onDraw function, draw that image as a bitmap, then draw the text exactly where you want.
Related
I am working on a widget, where I need to have a chart displayed in addition to some text fields. I have figured out how to generate a visualization of the graph and then convert it to a bitmap, which gets placed in the ImageView. The problem is the following:
In a normal Android app, I would get the width and height of the ImageView and pass these as parameters for the bitmap generation. This way, the image will be fitting perfectly within its container. Since I am using a home screen widget, this is not possible, as far as I am aware, though. As a result of this, I am trying to derive the size of the ImageView by trying to figure out what size would the text fields have, but I also have to calculate those and so far have had no luck with getting it right. What I end up with is always having excess space above and beneath the image, or on its sides and the size of this is really varying according to the screen the widget is presented on. You can see some examples in the two links below.
Example A This is the default widget size. For this screen, only a small gap can be seen on the sides of the graph.
Example B Resizing the widget and recalculating the size leads to having bigger gaps on the two sides, though. For other screens the issue can be even more jarring.
My question is:
How could I get/calculate the necessary resolution for my bitmap?
I am working on listView item in Unity and stuck at fitting the image properly in UI Image. I tried multiple things using Preserver Aspect Ratop, using Filled image type almost every thing but could not make it look fine. In android we call it center crop what i am trying to achieve. First image is with Preserve Aspect while the second one is without it.
What should i do to achieve it.
Thank you.
This is one way to do it that I can think of, using 2 images. The outer image is set at your desired size and have a Mask component:
The inner image is set at center of the outer image and scaled to fit the outer image (either programatically or by hand) It will be cropped by the outer image's mask and only display the area you want.
The blue rectangle in which test is written, how it is covering ,one full and some portion of lower and upper cell?, ,,, how these cells are made? , this isnt a simple grid. consider this ,what this layout contains, how blue rectangle can cover a specified area.?
help out
This is probably a custom view.
The background texture is a Bitmap , the cells are line drawn on a canvas and the blue area with text is a drawn rectangle.
When you create the view , you know oh many pixel represent an hour , so you should be able to give an exact position to the rectangle.
At least it's how i would do it.
You should have look at Creating Custom Views in android resources and more specificaly read Custom Drawing
To create such view you can:
create your custom view and draw on its canvas
use GridLayout that's available as a support library for android 2.1
I suggest to use the second variant.
I am working on an application in which I am using a frame layout. In the frame layout there are three classes as follows:
creating image
checking the pixel of the image the user touches
drawing the image
But when I am touching on the same color, it is giving me a different color value. If anyone wants to see my code then it is there. If you want to check which image is used by me then the images are as follows:
the second image which is used for getting the pixel:
Can any one tell me why it is not giving me correct value of the color on touch on the image
?
Edited1
my edited code of the imagein class is as follow [code after editing4
My guess is that you are making assumptions based on the the pixel coordinates of the image, and not translating the coordinates as they exist once Android resizes your art. You should see what Android thinks the image size is, after it's drawn to your View and make sure that the spot you're touching is the same spot that you're expecting to be touching.
hi,
I'm trying to implement something similar to the image attached. I have two textviews one on top of the other and i want their borders to look like the one in the image. I was able to draw rounded corners by setting the cornerradii of the GradientDrawable but i have no clue as in how to draw the slope on the right side of the first textview.
Any help on how to do this is much appreciated!!
thanks.
I would in this case do the graphics in a some graphics editing program (Photshop, GIMP or Inkscape for example). Two different drawings, one for the top part and one for the bottom. Then convert the drawings to NinePatchDrawable to be used as backgrounds for the text views. Since this type of drawable can be made larger or smaller depending on the length of the text in the TextViews.
You can use a transparent background image instead of drawing the background. Else you can use the canvas.
Edit : bad image example :-)