I have a tablerow which on a button touch, slowly fade out and go to invisible. For that I have used the following code.
private TableRow topRow = (TableRow) findViewById(R.id.topRow);
.....
.....
topRow.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_out));
topRow.setVisibility(View.INVISIBLE);
In another case, the row have to go down slowly(just like sunset) and become invisible. What change in the above code or how it is possible to arrange?
You want an animation that fades out (slowly turns down the alpha) and translates (moves the row down). This can be set in an animation xml resource file like so:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="50%p"
android:duration="@android:integer/config_longAnimTime"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@android:integer/config_longAnimTime" />
</set>
You then need to call your new animation (as you do in your code sample already), but now you need it to be visible before the animation starts. If you store your animation xml in the /res/anim/ folder as sunset.xml you should achieve what you want by including this code:
topRow.setVisibility(View.VISIBLE);
topRow.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(),R.anim.sunset));
topRow.setVisibility(View.INVISIBLE);