I'm trying to create a textview with a circular background such as shown in the image below. I have 6 other circles like this as well which come from user input.
However I run into problems if there are too many characters, it breaks the boundaries of the circle. I want to make the text go in a circular motion around the circle if the text is more than lets say 10 characters like this.
I've read other people have the same problem and the answers revolved around creating custom views. I am not that experienced with Java yet so if anyone can guide me through this I would really appreciate it.
Related
This question already has answers here:
How to Get Pixel Color in Android
(3 answers)
Closed 2 years ago.
I have a background image in my android studio project containing a little back circle.
What I want is to be able to detect this black circle when a ball move on the screen. Indeed I have a ball moving randomy on this background image, when the ball pass on the black circle, I want to detect it.
Does android have a feature for detecting pixels?
Actually, this black circle represents a hole, and I want to disappear the ball when it pass over the circle. I cannot use collision detection for some reasons
While the question is interesting, it can not be answered in the way you might hope.
To answer the title independently of the question:
Working with the data inside an app is not what Android Studio does.
Android Studio is used to build apps to run on Android, independent of Android Studio.
Inside an app, which can use the functionality provided by the Android system, detecting the color of a pixel in an image is certainly possible. That is a good question to ask at https://android.stackexchange.com/
The problem as you describe it may be very difficult, because you do not make many constraints. As an example, if that should work with any background, there could be black lines, for example.
I will simplify it to what I think you mean:
The app contains an image that contains a black circle that is much smaller than the image.
It also contains a second smaller circle, called the ball, in a different color.
The rest of the image has a third color, uniformly.
The problem you want to solve is: Move the ball, and find whether the smaller circle is completely inside the larger circle.
This is not easy, and quite interesting.
For this, you need to read pixel colors for parts of the image.
But it is unclear what you mean by "detecting pixels", and that may be an important point.
Reading pixels from an image that is part of your application should be simple.
What I described does not use collision detection, and the collision of the circles is irrelevant.
I am trying to use the Tap Target View library from GitHub in an android app.
https://github.com/KeepSafe/TapTargetView
I was wondering if anyone knows if we can use this library to highlight a rectangular shape or if it is primarily for targets that can be surrounded by a circle. I like to highlight an entire row in a list view.
Thanks
This library when reviewing the codes you find out there is no arc or circle in this customView and is a Rect...
So how is this circle like? It cause the radius number it gets. so if you know you can change the code very easily and remove or make the radius to 0.
But my question is why? really is going to make a bad mess for rectangular things...
So everyone, my first question on stackoverflow.
I have been working with android and openCV for a month and I was able to successfully implement template Matching. Now, the next task is to detect all the rectangles in the image and get the coordinates (I actually want the color of every rectangle) for research purposes. Kindly help. I tried using Hough transform with canny edge detection but unfortunately it doesn't detect the small rectangles which is the primary concern now.
Thank you!![![Have to detect all the rectangles, small and big ones
So I'm really proud to post an answer to my own question. Hope this helps someone in future. There are obviously a lot of ways to do this but the most accurate way was to use template matching on the main image to find the coordinates of the biggest rectangle and since all the other rectangles are equidistant to the corner points, center of every rectangle can be found which gives the desired colors.
The thin strip in the middle was also recognized by template matching and then a gradient operator represented the various rectangles, every peak in the gradient represents the rectangles.
Kindly comment for code. For research purposes I cannot post to anonymous.
Hi I am new to Android and I am currently experimenting with some Android features.
So I wanted to find a way to add flexibly add slices to a disk image (could be a pie chart or a roulette wheel). I have done some research on this topic, Drawable Resources | Android. If I wanted to insert a slice dynamically, I think the InsetDrawable method would best suit my situation. So that a bitmap would not be recreated every time the image changes. I have also gone over some tutorial on how to change Cartesian coordinates into Polar coordinates Android SDK: Creating a Rotating Dialer. I was hoping to combine the InsetDrawable method with the polar coordinates to achieve this function. So I was wondering if can anyone tell me whether or not my thoughts are feasible?
A sample of the image that I would like to get is shown below:
Instead of having 6 slices, the user could add more elements to populate the disk to make it 8 or 10 slices, or remove slices from the disk.
It would be great if anyone can share a link to some of the related topics or tutorials as such.
Thanks in advance :)
What is that you exactly want? If you want to dynamically add a slice every time you click a button, all you have to do is arrange the 6 slices in the form of a circle in the xml as 6 ImageViews. You will have to make these ImageViews invisible initially. And inside the onClick function of the button you make the ImageViews visible one by one.
I have recently completed a simple drag and drop shapes game. It had the user drag a shape (ImageView) to another "empty place holder" ImageView.
I now want to make this a little more advanced, instead of dragging a simple shape, I want to make a puzzle of various non-orthogonal shapes, for example breaking a circle into 5 different pieces. What I'm having a problem with right now is how to design the layout. I do not know how to make a truly "custom" shaped ImageView, as far as I can find from my research it's not possible. So my idea for now is to overlap a number of square ImageViews, each of which will have only a subset of an image and the rest transparent. Thus the final output will look like it's a number of custom shaped ImageViews.
Example:
+ + +
Because only the internal sections are "visible" and the rest of the circle is transparent, when all of these pieces are placed in the same spot on the screen, the final image will look like:
I haven't tried this yet... but I foresee at least one problem. When I go to drag the pieces over to this puzzle, they will all "snap" into place when dragged to the same place. Because in reality all I really have here is a picture of a circle inside a ImageView which has some invisible rectangular boundary around it.
Hopefully this situation is clear. Now my questions:
Is it possible to have truly custom shaped ImageViews instead of my idea of overlapping images?
If what I'm thinking is the best way to handle this puzzle idea, then what property can be changed such that the "drop" action does not happen at the same place for all of these puzzle pieces? If I wanted to "drop" the pizza shaped piece, I'd like it to only snap into place when it go close to the top left of the circle.
Note: I am new to Android programming, and somewhat new to Java/XML as well, it’s very likely I’m overlooking something, so please feel free to suggest other approaches as you see fit.
Not really. Overlapping views is generally the way it's done. You could also use one View and override the drawing action yourself (multiple bitmaps drawn at relative locations within the View), but that would make the drag-drop aspect significantly harder.
If the Views are all the same size, with the visible portions in the correct relative placement in each, they should snap together correctly. This is because the snap is (I believe) based on the position of the upper-left corner of the View. If the pizza-shaped piece's visible portion is correct with regards to that, it should snap in at exactly the right spot.
So you have certain places you want to accept the drops, and I'm assuming you know their coordinates, say (d_x,d_y).
Then why not simply monitor the coordinate of the center (p_x,p_y) of image view of the piece you are dragging, say the "pizza" piece, and when the distance between the the piece and drop point is within an acceptable amount accept the drop.
But if you are asking if there is some way to make non-rectangular image views I don't believe that is possible.
However I don't think it is necessary in your case, because I believe even if you want them to drag the piece precisely into place you can calculate the coordinates where the draggable rectangle needs to go with knowledge of the shape of the piece and the assumption that the rectangle wraps the piece.