animation interview questions
Top animation frequently asked interview questions
I need to stop running translate animation. The .cancel()
method of Animation
has no effect, the animation goes until the end anyway.
How do you cancel a running animation?
Source: (StackOverflow)
How do you animate the change of background color of a view in Android?
For example:
I have a view with a red background color. The background color of the view changes to blue. How can I do a smooth transition between colors?
If this can't be done with views, an alternative will be welcome.
Source: (StackOverflow)
How can I use .append()
with effects like show('slow')
Having effects on append
doesn't seem to work at all, and it give the same result as normal show()
. No transitions, no animations.
How can I append one div to another, and have a slideDown
or show('slow')
effect on it?
Source: (StackOverflow)
I'm trying to move some elements on the page, and during the time the animation occurs, I want to have "overflow:hidden" applied to an elemnt, and "overflow" back to "auto" once the animation is completed.
I know jQuery has an utility function that determines whether some element is being animated but I can't find it anywhere in the docs
Source: (StackOverflow)
So im trying to animate when i set the visibility of a linearlayout with other widgets, from GONE to VISIBLE and the opposite.Im using togglebuttons to show and hide. Here's an image to show what i want to do:
I can show and hide, but im not following how can i animate the sliding correctly....:(
Heres my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<!-- TITULO1 -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:background="#848284"
android:padding="4px">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:text="Informação Geral"
android:textColor="#FFFFFF"
android:gravity="left"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:textSize="18px"
android:paddingLeft="4px">
</TextView>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="right|center_vertical" android:gravity="right|center_vertical" android:paddingTop="2px">
<ToggleButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textOff="Expandir"
android:textOn="Minimizar"
android:id="@+id/mostrar"
android:width="80px">
</ToggleButton>
</LinearLayout>
</LinearLayout>
<!--LINHA SEPARADORA-->
<View
android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="2px">
</View>
<!-- CONTENT INITIALLY HIDDEN (GONE) -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/informgeral"
android:orientation="vertical">
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="5px"
android:paddingTop="5px"
android:paddingLeft="8px"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_nrprocesso"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/srch_number_proc"/>
<TextView
android:id="@+id/consult_nrprocessovalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:id="@+id/consult_tipoprocinfo"
android:text="Numero Atribuido ao Processo"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="1px">
</View>
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:paddingLeft="8px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_tipoproc"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/proc_type"/>
<TextView
android:id="@+id/consult_tipoprocvalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:id="@+id/consult_tipoprocinfo"
android:text="Variante do Processo em causa"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
<View android:id="@+id/View01"
android:layout_width="fill_parent"
android:background="#B5B5B5"
android:layout_height="1px">
</View>
<LinearLayout
android:id="@+id/LinearLayout03"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:paddingLeft="8px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_etapa"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/srch_task"/>
<TextView
android:id="@+id/consult_etapavalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:id="@+id/consult_etapainfo"
android:text="Etapa onde se encontra o processo"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
<View android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="1px">
</View>
<LinearLayout
android:id="@+id/LinearLayout04"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:paddingLeft="8px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_criadopor"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/criado_por"/>
<TextView
android:id="@+id/consult_criadoporvalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:id="@+id/consult_criadoporinfo"
android:text="Entidade responsável pela criação do Processo."
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
<View android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="1px">
</View>
<LinearLayout
android:id="@+id/LinearLayout05"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:paddingLeft="8px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_assunto"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/proc_subject"/>
<TextView
android:id="@+id/consult_assuntovalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:id="@+id/consult_assuntoinfo"
android:text="Assunto do Processo"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
<View android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="1px">
</View>
<LinearLayout
android:id="@+id/LinearLayout05"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:paddingLeft="8px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/consult_datainicio"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:ellipsize="end"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="@string/srch_datebeg"/>
<TextView
android:id="@+id/consult_datainiciovalue"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:id="@+id/consult_dataincioinfo"
android:text="Data da criação do Processo"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="wrap_content"
android:textSize="12px"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- TITULO2 -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:background="#848284" android:padding="4px">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:text="Informação Complementar"
android:textColor="#FFFFFF"
android:gravity="left"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical" android:paddingLeft="4px" android:textSize="16px">
</TextView>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="right|center_vertical"
android:gravity="right|center_vertical"
android:paddingTop="2px">
<ToggleButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textOff="Expandir"
android:textOn="Minimizar"
android:id="@+id/mostrar2"
android:width="80px">
</ToggleButton>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="2px">
</View>
<!-- TITULO3 -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:background="#848284"
android:padding="4px">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:text="Documentos Anexados"
android:textColor="#FFFFFF"
android:gravity="left"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:textSize="18px"
android:paddingLeft="4px">
</TextView>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="right|center_vertical"
android:gravity="right|center_vertical"
android:paddingTop="2px">
<ToggleButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textOff="Expandir"
android:textOn="Minimizar"
android:id="@+id/mostrar"
android:width="80px">
</ToggleButton>
</LinearLayout>
</LinearLayout>
<!--LINHA SEPARADORA-->
<View
android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="2px">
</View>
<!-- TITULO4 -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:background="#848284"
android:padding="4px">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:text="Etapas"
android:textColor="#FFFFFF"
android:gravity="left"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:textSize="18px"
android:paddingLeft="4px">
</TextView>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="right|center_vertical"
android:gravity="right|center_vertical"
android:paddingTop="2px">
<ToggleButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textOff="Expandir"
android:textOn="Minimizar"
android:id="@+id/mostrar"
android:width="80px">
</ToggleButton>
</LinearLayout>
</LinearLayout>
<!--LINHA SEPARADORA-->
<View
android:id="@+id/View01"
android:layout_width="wrap_content"
android:background="#B5B5B5"
android:layout_height="2px">
</View>
</LinearLayout>
</ScrollView>
And here's the java code that calls the button event:
final ToggleButton bt=(ToggleButton) findViewById(R.id.mostrar);
bt.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (bt.isChecked()) {
/*TranslateAnimation slide = new TranslateAnimation(0, 0, 0,
-findViewById(R.id.informgeral).getHeight()*2);
slide.setDuration(500);
slide.setFillAfter(true);
findViewById(R.id.informgeral).startAnimation(slide);*/
findViewById(R.id.informgeral).setVisibility(View.VISIBLE);;
} else {
/* TranslateAnimation slide = new TranslateAnimation(0, 0, 0,
findViewById(R.id.informgeral).getHeight());
slide.setDuration(500);
slide.setFillAfter(true);
findViewById(R.id.informgeral).startAnimation(slide);*/
//findViewById(R.id.listBut).startAnimation(slide);
findViewById(R.id.informgeral).setVisibility(View.GONE);;
}
}
});
Source: (StackOverflow)
I have a navigation based application and I want to change the animation of the push and pop animations. How would I do that?
Source: (StackOverflow)
I have two Activities A and B. I want to have the shrink Animation when
Activity A calls B and maximize animation when Activity B calls A. I don't need the animation xml files for this.
When we call another Activity in Android it gives its default animation and then it calls shrink animation.
What I want is that the default animation should not occur and the animation that I want should occur.
Can we actually give the animation when calling another Activity?
Source: (StackOverflow)
I have three activities whose launch modes are single instance.
Using onfling()
, I swing them left and right.
The problem is when I swipe right to left the slide transition is okay but when I swipe left to right, I get the transition of swiping right to left.
I know why this is happening its because I am always sending new intents. But, now I need to change the animation of sliding left to right.
I know there is a method named overridingTransitionPending()
, but I do not know how to define my animation in XML.
Source: (StackOverflow)
I want to make an Animation
for when a View
gets it's visibility set to GONE
. Instead of just dissapearing, the View
should 'collapse'. I tried this with a ScaleAnimation
but then the View
is collapse, but the layout will only resize it's space after (or before) the Animation
stops (or starts).
How can I make the Animation
so that, while animating, the lower View
s will stay directly below the content, instead of having a blank space?
Source: (StackOverflow)
How can I use properly the Intent flag FLAG_ACTIVITY_NO_ANIMATION
in AndroidManifest file? I supose my problem is trivial, but I can't find good example or solution to it.
<intent-filter>
<data android:name="android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION" />
</intent-filter>
However no error is reported by compliator, but data
isn't correct.
I just want to disable animation in case switching between activities. I can use getWindow().setWindowAnimations(0);
in onCreate or onResume rather but using flag is better way, isn't it?
I can use also in code:
Intent intent = new Intent(v.getContext(), newactivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
getContext().startActivity(intent);
But I want to use this flag in Android Manifest. To disable animation also in case returning from second activity to first.
Source: (StackOverflow)
I currently have a view in my Android app and the view is playing a frame animation. I want to animate the view to increase its size to 150%. When I apply a scale animation to it, and the scale animation is completed, I want the view to stay at that new size for the rest of the activity's life cycle. Unfortunately right now when the scale up animation is complete, the view snaps back to the original size. How can I get it to keep the new animated tranformation?
I'm using
myView.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.scaleUp150));
Thanks!
Source: (StackOverflow)
I have this line of JavaScript and the behavior I am seeing is that the selectedLi
instantly disappears without "sliding up". This is not the behavior that I expected.
What should I be doing so that the selectedLi
slides up before it is removed?
selectedLi.slideUp("normal").remove();
Source: (StackOverflow)
<img class="image" src="" alt="" width="120" height="120">
Can not get this animated image to work, it is supposed to do a 360 degrees rotation.
I guess something's wrong with the CSS below, as it just stays still.
.image {
float: left;
margin: 0 auto;
position: absolute;
top: 50%;
left: 50%;
width: 120px;
height: 120px;
margin-top: -60px;
margin-left: -60px;
-webkit-animation-name: spin;
-webkit-animation-duration: 4000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: spin;
-moz-animation-duration: 4000ms;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: spin;
-ms-animation-duration: 4000ms;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: spin;
animation-duration: 4000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
@-ms-keyframes spin {
from {
-ms-transform: rotate(0deg);
} to {
-ms-transform: rotate(360deg);
}
}
@-moz-keyframes spin {
from {
-moz-transform: rotate(0deg);
} to {
-moz-transform: rotate(360deg);
}
}
@-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
} to {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
from {
transform: rotate(0deg);
} to {
transform: rotate(360deg);
}
}
}
Source: (StackOverflow)
I want to have a 2 second animation of an ImageView that spends 1000ms fading in and then 1000ms fading out.
Here's what I have so far in my ImageView constructor:
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setDuration(1000);
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setStartOffset(1000);
fadeOut.setDuration(1000);
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
this.setAnimation(animation);
When I run that animation, nothing shows up. However, when I remove one of the alpha animations, the behavior works as expected.
Things I have already tried:
- Every conceivable combination of
setFillBefore
, setFillAfter
, and setFillEnabled
.
- Adding a
LinearInterpolator
to the AnimationSet
.
Source: (StackOverflow)
This is the iphone site:
http://www.thevisionairegroup.com/projects/accessorizer/site/
After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are:
'-webkit-transition': 'none'
'-webkit-transition': 'all 0.2s ease-out'
'-webkit-transform': 'translate(XXpx, XXpx)'
I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around.
The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
Source: (StackOverflow)