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.
Related
I'm trying to learn App Inventor 2, by implementing the tutorials and redo some in another way. I'm currently trying to make a compass similar to this, but instead of the classic rotating disk, I want to have a linear display, something like this.
Should the code blocks used in the rotating compass be altered in a way, to have the linear compass effect? By simply changing the displaying image does not work.
I'm currently using this block combination:
"when OrientationSensor1.OrientationChanged
do set Compass.Heading to get azimuth +180 (to get N always)"
Can someone give me a clue on how to implement a working linear compass in app Inventor 2, if it is possible? Thank you all in advance for your answers.
You can draw one yourself using the canvas.
Check this example how to render it, it draws the North mark only, but you can extend it easily to draw all other marks...
Before use I would try if this approach (redrawing the old position of marks) is not slower of faster than clearing the whole canvas (might perform faster).
Good luck.
I'm making a board for Android. I use .png images for the board (background) and checker pieces. Basically, it's a game where the graphics are updated upon touch events. It's a school-assignment so I have to use View implementations. For the graphics I've considered two options:
Making a whole "BoardView" class (that extends View) and draw all the graphic components directly on the canvas using onDraw(canvas).
Using ImageView objects to represent each checker piece and the board and putting them on a Layout.
My intuition tells me to use the first method. But my thoughts are that I want to use the pre-implemented TranslateAnimation when a checker is moved. From my understandings; this forces me to use the second method, since I can't animate a Drawable.
Now, to the question: what method is best for me? And if the second; which Layout is preferred to use? I want to be able to overlap the checkers over the board image and compare the ImageView objects' positions to each other to determine where to put the checkers on the board.
Regarding to your simple requirement, I think you can adopt method 2.
Trust me, I have done this kind of stuff years ago, on a legacy linux platform. For these kind of simple game applications, you really do not need to bother with all the frame drawing stuff. Just stick with the existing UI widgets.
This is because the visible elements are all very simple, like cards, static images, blocks etc. You don't need to perform pixel drawing. I have tried to make tetris, mine sweep, and card match games. I even create simple visual effects for it using existing animation facility. That is very easy to do so.
And, of cause, as a software programmer, to write a game using the typical frame by frame approach is much more professional. But it depends on the requirements. Why not using less code to create more value?
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.
Im experienced iOS dev but new to Android dev and asking some newbie questions here...
I have to make a app where I have a background image and I then place some other images on top of that, and also onto those images I have to place different "glow" images that flicker (opacity on/off), and I need good control on positioning all those images. Now there is not some high performance goal here, and its not many objects, its not really a game.
What is the best approach for this? Can I use ImageView's for this or will it be better to use a Surface and custom draw in a thread?
And please, what ever you suggest, can you give a link to a good tutorial on the approach (ImageView or custom draw), I need all the help I can on this project with its crazy deadline.
Thank you
Søren
In my experience:
if its mostly static you should stick to XML and stuff like ImageViews etc
if its simple animations, the predefined android classes are fine and somewhat easy to use
if you want real custom then drawing with canvas is the way to go
You can extend View and override the onDraw method or create a SurfaceView which has better performance but is not that easy to use.
(sorry i dont have any tutorial links)
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.