I run into a difficulty in my application.
I have an ImageView that represents a chemistry flask.
I would like that when I click on buttons of various colors, the ImageView is filled with the said color.
I would like a stack of each separate color but if you have a solution for mixing every color (maybe in a gradient ? it will be ok too)
I would have 12 colors at the end in total
The problem is that I don't know how to do it.
Anyone have an idea?
Example:
I click on a button which corresponds to the color blue :
Then I click on a button which corresponds to the color red:
I would go with Canvas.
You can first draw solution, and then add drawing of the flask on top of that.
First, I'd measure the height of the flask in pixels so that I'd be able to calculate how much pixels in height does 1 unit of volume take. After that, you can add separate solutions based on number of units and start drawing at the top of last one.
Once you draw all the solutions, just draw image of flask on the same canvas.
Related
Is there any solutions for this problem :
I want these two shapes with blue and pink colors to be separate buttons so whenever the pink space is clicked something happened and the same for the blue space.
PS: i can slice the two portions and create an ImageButton for each but the problem is the button doesn't take the same shape of a portion it is always rectangular so i can't place the other button next to it
I'd suppose to recommend you to write a custom View, that draw this picture itself, depending on some kind of formulae.
Or use an old method of game development when you define color of pixel that was touched or focused.
Define color of pixel touched
PS: i can slice the two portions and create an ImageButton for each but the problem is they don't fit good on the activity
Try to use 9 patch resources or svg drawables instead.
If they are defined well it should work.
Then you will have to write you're own custom button the uses them.
You can read more about it here:
http://www.vogella.com/tutorials/AndroidDrawables/article.html#9-patch-drawables
http://www.vogella.com/tutorials/AndroidDrawables/article.html#vector-drawables
I want create images for each state.. (texas,montana,california.....)
Example image USA map :
I tried put images over and over for each states like below (50 states, 50 images)..
For example Texas image :
It was bad way.. Can i achieve this another way? or different opinion?
Use free crop in PicsArt. Go to edit and select the picture. Select tools and then free crop. Colour in the bit you want to keep and save it. I hope this helps!
I'd suggest you using 2 ImageViews - one on the top of another. On the bottom ImageView you can draw image of whole map without the State names.
On the top ImageView you can draw the names only.
Then you set onTouchListener to the ImageView, and on touch you just get the color of touched pixel. After that you match touched color with the state colors, and this way you know, which state was clicked.
For this every state has to have it's own color.
So I have this image set as the background of a seekbar. On different screens, the image gets skewed so much that it is quite horrible. I tried doing a 9 patch, but obviously there are several regions I would like to scale so 9 patch wasnt the best option. What I would like to acheive is, have the background stretched and leave the numbers proportional. The numbers tend to eith stretch too much or shrink too much.
Any help is appreciated.
Thanks
The simplest option here is probably to create a GradientDrawable to set as the background of your view. You can see from the docs that GradientDrawable can take an array of colors in its constructor, and it will draw all those colors evenly spaced across whatever size the enclosing view end up to be. This is the same element used to create <shape> drawables in XML, but if you instantiate it in Java code you can add more than just three colors to the gradient scale.
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 :-)
I want to create a circle layout. All of my views should be in the circle. Which layout do I have to prefer and how? The focus of the layout should be a clockwise circle.
Edit:
I can do this view and it is an update of my question, prompted by the comments to this question. Is there any example for doing that?
The screenshot is attached below.
image http://www.freeimagehosting.net/uploads/e11f35e522.png
For people who is coming to this question now I recently had to implement this circle layout and after a lot of searching I decide that a relative layout that draws a petal shaped buttons will not give me the effect I needed so I followed those steps
you can see if you tested the nbc app on iphone they are placing invisible buttons on the words and the circle is just an image with the button overlaid but I didn't like this solution .
So here's how I implemented it
1- asked for the flower with the words on it from the UI guy and told him that the colors must be solid no gradient what so ever and then asked him to send me the hexadecimal values of each color.
2- then I implemented a motion listener that checks the color of the pixel the user clicked on ACTION_UP event and launch the event corresponding with the category of that color .
3-I check the color by getting x & y from the listener and then get the color from the image bitmap
I'll post snippets of the code If anyone needs it but I don't have it on me now.