Creating a Splash Screen in App in Android.
Android Project Structure:
src folder has packages which contains our source code
gen folder which is generated by android complier to map the xml components in Java code.
res folder contains drawable , layout, anim, raw,values folder, drawable is manily for image handling and layout folder contains xml codes and anim folder is for holding animation files and raw folder is storing for excel files as well as Music files and values folder hold the gobal variables.
Step 1: For Designing an UI, we have to code in xml,
Create a xml file, namely myui.xml Note: use small char when you naming the xml files
The first line of your xml must be this line to indicate to android complier which version and encoding type of our xml is using
<?xml version="1.0" encoding="utf-8"?>
Then create a Layout , we have four different types of layout, they are Linear Layouts and Relative Layouts and Absolute Layout and Table Layout.
Linear layout is used when the UI components are arranged in an linear manner either in horizontal or veritical.
Relative Layout is used when there is a relationship b/w the UI componenets
Absolute layout is used when UI components are hardcoded.
Tablelayout is when the UI has to be arranged in the form of Rows and Columns.
For Splash Screen App, we choose Linear layout and set the Image as background to Linear layout as i shown below
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mysplashimg">
Step2: Creating Java Code
Extend your java class from android Activity class, and donot forget to override onCreate method
package declaration
public class MyActivity extends Activity
{
// create and set value for CountDown Timer Object
MyCount counter = new MyCount(5000, 1000);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Map your UI in xml here as shown i below
setContentView(R.layout.myui);
counter.start(); // Start the Count Down Timer
}
}
Step 3: Create a Class which extends CountDown Timer
class MyCount extends CountDownTimer {
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onFinish() {
// Finish your Splash screen and Jump to other Activity with the help of Intent
Intent my_intentObj= new Intent(Currentclass.this, Movableclass.class);
startActivity( my_intentObj);
}
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
}
}
Android Project Structure:
src folder has packages which contains our source code
gen folder which is generated by android complier to map the xml components in Java code.
res folder contains drawable , layout, anim, raw,values folder, drawable is manily for image handling and layout folder contains xml codes and anim folder is for holding animation files and raw folder is storing for excel files as well as Music files and values folder hold the gobal variables.
Step 1: For Designing an UI, we have to code in xml,
Create a xml file, namely myui.xml Note: use small char when you naming the xml files
The first line of your xml must be this line to indicate to android complier which version and encoding type of our xml is using
<?xml version="1.0" encoding="utf-8"?>
Then create a Layout , we have four different types of layout, they are Linear Layouts and Relative Layouts and Absolute Layout and Table Layout.
Linear layout is used when the UI components are arranged in an linear manner either in horizontal or veritical.
Relative Layout is used when there is a relationship b/w the UI componenets
Absolute layout is used when UI components are hardcoded.
Tablelayout is when the UI has to be arranged in the form of Rows and Columns.
For Splash Screen App, we choose Linear layout and set the Image as background to Linear layout as i shown below
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mysplashimg">
Step2: Creating Java Code
Extend your java class from android Activity class, and donot forget to override onCreate method
package declaration
public class MyActivity extends Activity
{
// create and set value for CountDown Timer Object
MyCount counter = new MyCount(5000, 1000);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Map your UI in xml here as shown i below
setContentView(R.layout.myui);
counter.start(); // Start the Count Down Timer
}
}
Step 3: Create a Class which extends CountDown Timer
class MyCount extends CountDownTimer {
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onFinish() {
// Finish your Splash screen and Jump to other Activity with the help of Intent
Intent my_intentObj= new Intent(Currentclass.this, Movableclass.class);
startActivity( my_intentObj);
}
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
}
}
all the applications u posted here,ll be very useful for me..thanks
ReplyDelete