i am developing app, in which i want am image to move along a curve path in the background screen.i am able to move the image from one point to another using the below translate xml, but its moving along a straight path, i want it to move along a curve path.how can i achieve this?
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="3000"
android:fromXDelta="-20%"
android:fromYDelta="-10%"
android:toXDelta="150%"
android:toYDelta="-130%"
android:zAdjustment="normal" />
please help.thanks!
<rotate
android:toDegrees="360"
android:pivotX="100%"
android:pivotY="200%"
android:duration="6000"
android:repeatMode="restart"
android:repeatCount="infinite"/>
Workaround: I used rotate and played with pivotX and pivotY and image position
Related
I'm new to Android developing. I want some animations when clicking on the card and it will move around the screen and stay at its new position forever (its interactive area should change too).
At first the card is located at the center-bottom of the screen (XDelta= 50% YDelta = 70%) then it will move up straight to center of the screen (XDelta =50% and YDelta is 40%). Then it will move to its upper left (10 dp from the left of the screen and 10 dp from the top of the screen) Sorry I can't post images due to my lack of reputation.
And here's my code in res/anim/card1.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="50%"
android:fromYDelta="70%"
android:toYDelta="40%"
android:toXDelta="50%"
android:fillEnabled="true"/>
<translate
android:duration="100"
android:fillEnabled="true"
android:fromXDelta="50%"
android:fromYDelta="40%"
android:startOffset="200"
android:toXDelta="10"
android:toYDelta="10" />
</set>
And code to get it work when clicking on the card
Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.card1);
iv_card.startAnimation(anim);
... but it just don't animate the way I want. Please help me!!!!
Check Out this (http://www.tktutorials.com/2013/07/animation-in-android-using-xml-files.html) this may help your need. Alter the translate.xml file as per your need, which is located in Res->anim->translate.xml
And solution for your posting Image. My suggestion is upload your pic in googleDrive, then change the share setting for the particular pic from private to Public on web and use the url Link to your question.
Hi I have a problem with controlling position of my object on the screen. When I create activity every object on the screen is placed with animation and troubles starting here. Firstly I tried to placed all things with pixel coordinates, which based on height and width of screen. I want to take it from device when activity starts. During the coding I think the better way will be use the % values cause I don't need to think about diferent screen resolution and stuff like this.
The picture shows, how I thought the screen looks with different values,but I'm wrong.I make the assumption, that the layout match to the parent, so it have nearly this same size as the screen
Cause the range of values for % and %p is from -100 to 100, so where is -100%, when I put something like -60%p I can't see it on the screen. I try to play with the object by changing the values and see results, but for example
object represented by
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true"
android:duration="3000"
android:startOffset="7000">
<translate
android:fromXDelta="2600"
android:toXDelta="0%p"
android:fromYDelta="-10"
android:toYDelta="-10%p"
/>
<rotate
android:fromDegrees="359"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
/>
is higher on the screen then object represented by:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true"
android:duration="3000"
android:startOffset="12000">
<rotate
android:fromDegrees="359"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
/>
<translate
android:fromXDelta="-599"
android:toXDelta="40%p"
android:fromYDelta="-499"
android:toYDelta="-10%p"
/>
I think they should be on this same vertical level, because android:toYDelta is the same.
When we are putting the values to xml code, we are placing the right top corner of the object in my opinion.
Please clear the way I think about coordinates of different type, and where are mistakes?
I would be grateful for every answer.
I am new to android development, can any one tell me how to rotate entire a button into 45 degrees along with text and button rect. I want to rotate permanently and i want on click listener on the same.
You need to use animations for that.
in your /res/anim/ you must create an xml file with this:
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:duration="0"
android:startOffset="0"
/>
and the in your Activity:
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.YOUR_ANIM);
ranim.setFillAfter(true);
YourButton.setAnimation(ranim);
Apart from that it seems that there are some problems with diagonal rotations (a.k.a. 45 degrees) pre-honeycomb..
I need to rotate my image in my on touch listener when the user touches it. I am rotating a dial graphic, so it needs to rotate around its center point. Does anyone have an example?
I'd refer to the actual android documentation for animation here: http://developer.android.com/guide/topics/resources/animation-resource.html
As for setting up the rotation in an xml, it will look something like:
<set android:interpolator="#anim/linear_interpolator">
<rotate
android:fromDegrees="180"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:duration="1000">
</rotate>
</set>
That is for a 180 rotation.
I require an animation for an image in my application.
The image should start coming from the top left corner till the middle of screen. The image size will be smaller at the initial stage. While coming to the middle of the screen, its size should increase(i.e. scaling should take place). Image should not go back to its original position. It should be placed at the middle of the screen itself after the animation.
Can anyone please help.
Please find the answer here.
Create an xml inside /res/anim folder and put the below code into it.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/linear_interpolator">
<scale android:fromXScale="0.0" android:fromYScale="0.0"
android:toXScale="1.0" android:toYScale="1.0"
android:duration="700" android:fillBefore="false" />
<translate android:fromXDelta="-200" android:fromYDelta="-200"
android:duration="700" />
</set>
Place the below code inside the java file:
Animation logoMoveAnimation = AnimationUtils.loadAnimation(this, R.anim.logoanimation);
logoIV.startAnimation(logoMoveAnimation);
logoanimation is the name of my animation xml file.
Thanks for all those who tried out for my question.