Creating Gif Animation in Android
1. Create a new Android Project.
2. Add the below code in your Main_activity
//******************Main_activity*************************
public class Your_Class extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Gif_loading_View view = new Gif_loading_View(this);
setContentView(view);
}
}
//Adding the webView
public class Gif_loading_View extends WebView{
public Gif_loading_View(Context context) {
super(context);
loadUrl("file:///android_asset/loading_position.html");
}
}
//**************************************************************
3.Create a file "loading_position.html" and add the below code inside and svae it.
<html>
<body bgcolor="white">
<table width="100%" height="100%">
<tr>
<td align="center" valign="center">
<br/>
<br/>
<br/>
<font size="6">Please wait...</font>
<br/>
<br/>
<img src="your_gif_filename.gif" />
</td>
</tr>
</table>
</body>
4. Copy paste the html file inside "assets" folder in your project.
5. Copy paste any gif file from the internet and rename it as "your_gif_filename"
6. Paste it inside the same assets folder
7.Run the project
No comments:
Post a Comment