I have provided a picture below so you can get a better understanding. Basically I want the user to pick a number from 1-10 which is shown by circles (Only 1 number can be picked at a time). Lets say I pick number 10, as you can see on the picture I want the circle to stroke and change the color when the number is picked (indicating to the user that the number has been chosen). After the number is picked and you press the "blue button", I want to get the value picked to do other calculations.
This is how I want it to be
I feel having a touch based circle is the best way to do it, rather than using a spinner because it take more time. Now the question is how to do this without code duplication or redundancy and how to achieve this in the best way possible. I am thinking I have to create a circle object (Possibly button shaped like circles) 10 times and put text on them, group them in array?..etc or is there a more efficient way to do this.
I'm sure there's better ways to achieve this but I suggest a simple solution as you wanted !!!
Now the question is how to do this without code duplication or redundancy?
You can create a xml file in your drawable folder and put two different oval shapes in that: defaultShape and pickedShape, Use <solid> and <stroke> tags to customize your shapes as you like, and then apply it to your buttons' background.
In order to handle the picking of your button you should implement same onClickListenerfor all 10 buttons, if one of them is picked save it to a temp variable like Button pickedButton, in your listener your check if pickedButton is not null change its background to defaultShape, and assign the new picked one to the pickedButton and then change its background to pickedShape.
Hope you find it helpful.
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.
I have an Android app which lets the user process some photos, adding filters.
One of them is to add a datestamp to the photo, which can have only the date or both date and time.
What I need to do is, given a photo as input, even if that photo has been compressed, for example, in order to be sent through a messaging app, determine if that image has been datestamped previously or not.
Of course, I'm not asking about a complete implementation, but about a few ideas.
Right now I thought about marking some pixels of the image and then, by using HSV, try to find a similar color to the one initially set in that position.
Another approach I thought about was to try to locate the text, but my problem is that the possible positions are the four corners of the image (user chooses), and the color can be one of 27 different colors, so I cannot search for yellow on the lower-right corner of the image.
But, anyway, any idea about how to locate the date if it was always yellow and located on the lower-right corner are welcome.
Do you have any ideas?
Thank you.
photo: https://imageshack.com/i/f0LwsdJPj
http://imagizer.imageshack.us/v2/xq90/540/LwsdJP.jpg
There is my draft, it is supposed to be like a "card library". My idea was to copy this "draf" and to have 1 pic.png for every card on the library, then when user drags the screen to one side, or touches the arrows it changes picture.
I have some questions. Is there any other way more efficient to do this? like having the same background for all them then changing only text inside them?
I'm doing it with canvas, i do: bitmapFactory.decode image ... then draw bitmap somewhere on the screen. Then, it's not an imageview so I don't know how to change text depending on device language.
Other solution could be something like canvas.WriteText somewhere but it doesn't exist, does it?
Last but not least, I have another problem with this "card" library. The "stars" drawn next to the numbers, should be shining or not depending on the user has the star or not. Do I have to copy an image with every combination? or is there any way to change only 1 part of the picture without building it with photoshop?
I am completely new here and to developing apps. I following a basic tutorial:
http://code.tutsplus.com/tutorials/android-sdk-create-a-drawing-app-interface-creation--mobile-19021
It has three parts to the tutorial. But eventually you have an app that can draw with multiple colors, can erase, save, change the brush size and start with a new canvas.
My aim is to add an option for the user to choose a background for the canvas. I have already set a drawable to be the background for the canvas currently used. So that the kids can "color in". I now want to add a button which lets that change the background of the canvas. I would like to let them choose between 9 different "templates"
As the app has many different pieces of code, and i dont know exactly which one to paste here, please go to the tutorial page to see all the code that was used. OR just ask me which part to paste in here.
Sorry if I am being unclear or vague, but im really an early beginner.
Thanks so much.
Try overriding the onDraw method of your custom view for coloring in so that, before it draws the background drawable you have assigned, it fills itself with the color the child has selected and then change your drawable so that it is transparent apart from a hollow sketch of the object they are coloring in.
You can also work in layers by separating the background color, the drawable and the childs scribbles in three views on top of each other and combine them only when you come to save the finished work.