- I doesn't know how to move an image right to left slide in SplashActivity.
- Below I posted a code for SplashActivity.I got an output.But Images wasn't slide.It displays an image simply one after another.
SplashActivity.java:
public class SplashActivity extends FragmentActivity {
// create object of progressbar
ProgressBar prgLoading;
// set variable for progress bar to 0
int progress = 0;
private View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_splash);
Animation slide = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_in_left);
final ImageView splashImageView = (ImageView) findViewById(R.id.splashImageView);
splashImageView.setBackgroundResource(R.anim.splash);
final AnimationDrawable frameAnimation = (AnimationDrawable) splashImageView
.getBackground();
view.startAnimation(slide);
Thread timer = new Thread() {
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent splash = new Intent(SplashActivity.this,
HomeActivity.class);
startActivity(splash);
}
}
};
timer.start();
splashImageView.post(new Runnable() {
@Override
public void run() {
frameAnimation.start();
}
});
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
layout_splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs" >
<ImageView
android:id="@+id/splashImageView"
android:background="@drawable/spl1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
In res/anim/slide_in_left.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="1000" android:fromXDelta="0%" android:toXDelta="-100%"/>
<alpha android:duration="1000" android:fromAlpha="1.0" android:toAlpha="0.0" />
</set>
In res/anim/splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flaganim"
android:oneshot="false"
>
<item android:drawable="@drawable/spl1" android:duration="2000" />
<item android:drawable="@drawable/spl2" android:duration="2000" />
<item android:drawable="@drawable/spl3" android:duration="2000" />
</animation-list>
- I got an output as three images simply display one after another.But Images doesn't slide from Right to Left.
- Anybody can help me if you know how to solve these.Thank you.