Unfortunately in some cases we face troublesome limitations. Lest see them through an example:
We will create a simple animation that moves a buttom from the top left corner of the screen to the center when it is clicked, then remains there, and when clicked again it moves back to its original position
After you read the documentation http://developer.android.com/guide/topics/resources/animation-resource.h... it may seem easy to solve. We can define the animation realative to the parents size in percent (50%p), and the fillAfter attribute makes the button remain there, insted of jumping back to its original position. We can even define all of this in XML. So most of the problem seems to be solved with the few line of XML below:
This animations can be highly customized and combined, for example we can set the speed, delay, acceleration, duration of animations, then group them together in an AnimationSet.
Animations can be applyed as Layout animations to ViewGroups, to be triggered when the ViewGroup is created/displayed or applied to any view and be triggered by us any time.
The animations can be definex in XMl or by code. Defining in xml is mutch more clear, but you can not set animation parameters dinamically.
The animation XML files should be created in the res/anim folder and can be accessed using the R class, like R.anim.animation_name.
An animation defined in hyperspace_jump.xml can look like this:
There are situations where you have to use a Canvas. What do you do if you have more text than you can properly display?
The problem is, that if you want multiline text on canvas, with the drawText method, you would have to measure how much space a single line of text would take up, and also compare it to the width of the screen, and draw each line separately.
Read more to check my solution.
In this tutorial I'm going to show you how to process an image and draw it's color histogram.
First you have to create a new Android project with the following parameters.
Project name: ViewfinderEE368
Check the box for Android 2.0.1
Application name: Viewfinder EE368
Package name: com.example.viewfinderee368
Check the box for Create Activity and enter: ViewfinderEE368
Min SDK Version: 6
Drawing 9patch can turn into a nightmare easily. I would like to present the other side. The most common problem, to create draws wich are look well in portrait mode and landscape mode too.
Example One: Simple button
This is a just simple button, with a glowing effect. The 9patching wich I use here, keeps the button’s edges, so it keeps the rounded rectangle’s radius too. With 9patch, the content area of the button can be set easily.
Lately we have been doing all kinds of demo projects, and tests, where we did not want to use constant data to present our products. Having a demo of your application is only nice, if it has relevant data in it. It could be top class technology, but if it is using the same image 20 times in a list, well that does not look very good.
Getting 20 relevant images on a subject takes up a lot of time, even with search engines and royalty free photo sites.Luckily most search able sites have free apis, here is a little snippet for flickr's services.
This article was requested by some of our community members. It is based on the Android Gallery, ImageView Example tutorial by Sasikumar (Part 1 is here). I extended his example with a new function. If you long click on the big image, an alert dialog show up and ask “Do you want to use this image as a wallpaper?". If you click yes, the actually image will be your new wallpaper.
So in this tutorial I'm going to show you how to refresh imageviews' contents periodically (let say by Handlers if you download the picture from web).
I had painful 2 days figuring out what's a good solution here, I tried to give IDs to imageviews and that sort of sick things, but believe me, it wasn't worth it. The solution is so simply that I hardly can believe.
What we're lookign for here is instead of create new Adapters and HashMaps (which contains ListView data), we just update it's values, and Android will do the trick for us.
The most important thing is DO NOT AT ANY CIRCUMSTANCES CREATE A NEW ADAPTER (or a new data source that holds the Adapter's data).
There's an exception of course, you obviously have to create a new Adapter in OnCreate() { }.