I am creating a simple word puzzle where i will need to draw a 16 *16 grid of textviews.
My two options are using a layout or creating one programmatically. I assume the one created programmatically will be very slow while the one created using an xml will be tricky to create. What other options do i have.
If anyone has created one before, can you share your experiences ? The grid will be very much alike a cross word puzzle grid.
Kind Regards,
I would suggest using an XML layout. You can create a reusable style so the XML will be less verbose. It won't be nearly as complicated as the Canvas route because each TextBox will be its own view, with its own handlers. With a Canvas, you would have to manage drawing and detecting change based on coordinates.
Related
Once again I started to experiment with Android things. I'm trying to create a small simple game, which uses a hexagonal board. I know the math behind the hexagonal calculations, but the problem is how to actually implement such board in Android?
At first I thought of using a grid view where every other line is displaced by half step and then use these square grids as my board and just draw a hexagonal shape over the square boxes. However, the regular grid view doesn't seem to allow me to do that.
So I thought that maybe I need to create a custom view with either hexagonal grid or a custom view with square displaced grid.
I'm not familiar with Android custom views. I read a tutorial about custom views from Vogella's tutorials but I'm still very unsure, if it's even possible to create a hexagonal grid as a custom view.
So any ideas and help of how to create and implement a hexagonal game board on android?
I would certainly go with a custom view for this. When you draw the view, you can have a loop that draws each hexagonal tile in the right place within the view as a whole. This will give you the most flexibility.
I suggest you start by writing a method that determines, for any given point within the whole view, which hexagonal tile it's in. You'll need this for determining which tile was touched, and it will also help with the drawing.
The nice thing about it is that if you keep track of the centre of each tile, then for any given point, the nearest centre point will tell you which tile the point is located in.
I need to develop an app to design a watch, as a beginner to android, i'm in need of two suggestion,
1) How to arrange the tick (for each hour in a watch) circularly?
2) Am i go with custom layout to arrange the ticks and labels? or use the same logic inside a method itself?
I hope the question is clear, Thanks in advance.
Joy Rex
Reading your question ther very first thing came in my mind is
GaudgeView
You may need to customize it for second and minute hand. But you will have lot more clear idea with this widget to start with.
Its extends the View class and works on Canvas.
He has provided some customizations options too.
How to arrange the tick (for each hour in a watch) circularly?
I would recommend using an image for that because it would be easy and faster in rendering it on the canvas rather than drawing each tick on the canvas, you can create the image in Photoshop or your favorite editing tool.
Am i go with custom layout to arrange the ticks and labels? or use the same logic inside a method itself?
Yes you need custom layout, if you are planning to implement animation of the big and small hand of the clock you can can again create an image for small and big hand and draw it in canvas and for animating you can use the matrix.postRotate from the Matrix class to rotate the arms of the clock each second,minute,hours.
Does anybody have any idea on how to approach custom UI for an app?
I mean, there are several amazing looking apps out there, that DO NOT look like they were made using the layouts and views offered by Android.
Such as: PIE UI,
Color in the Dark, or look at this collection Collection
I basically want to know how to draw custom shapes and arrange them while making them clickable.
I know how to draw regular custom shapes, but how do I arrange them how do I make really custom shapes like parts of a circle or an ellipsis or even irregular shapes?
I know a little Photoshop, so there I can draw whatever my imagination lets me, but how do I integrate yhe images/shapes drawn there in the UI since I cannot place a shape by it's coordinates? Not all shapes can be placed inside a rectangle, because some parts might overlap. So how are they doing it?
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 am working on a project that involves painting on images.
To delete the unwanted lines or curves i have to draw a border and X button to delete it.
I have a relative layout where i have the freehand drawing canvas. on edit mode i should make them as u see in the pic, where i have to create button on a varying x,y positions.
i am confused how to achieve this.
Thanks in advance.
Jana.
I suggest doing this manually rather than using the Button widget. Override the onTouchEvent on the view holding your painting and use MotionEvent.getX and MotionEvent.getY in combination with MotionEvent.getAction to determine behaviour when the user touches the 'button'. Skipping widget creation will improve performance and open up doors to other types of functionality.
You could use the deprecated AbsoluteLayout container for this or keep the RelativeLayout and use layoutMargins to set the location of the buttons. The former is the route you should take despite the container being deprecated as the later breaks the layout paradigm by misusing margins...
You should keep in mind that there are a variety of devices with different screen sizes and setting explicit, pixel based locations is going to be awkward.