Introduction :
Creating graphics applications in Android Studio IDE is allow you to show your creativity. If you want to develop a game, drawing app or any other graphic related application, Android Studio is the best tools to bring your vision to life. In this article, I shall show you how to create a simple graphics application for android phone using Android Studio.
About the application :
This is a simple graphics application. When you open the app on your Android phone, you can see circle will create and then disappear on the screen. This makes the graphics app an animation effect.
Step for create the application :
The following step you have to follow to make the graphics app for android phone.
Step 1 :
In the beginning, open Android Studio on your PC. Now, create a new project with empty activity and name it as ‘Graphic_Application’. If you do not know how to create an Android app, you can follow my link.
Step 2 :
Then, you can see a default project is opened on your Android Studio IDE. First, open the activity_main.xml file and replace the default code with the following code.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/image_id"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.constraint.ConstraintLayout>
Step 3 :
Now, open the MainActivity.java file and replace the default code with the following code. Here, you have to keep the first line same as your default code such as “package com.example.Graphic_Application;”
package com.example.graphic_application;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
public class MainActivity extends Activity {
ImageView image;
Canvas canvas;
Bitmap bitmap;
Paint paint,paint1,paint2;
Handler handler;
Runnable runnable;
int i=0,j=0,w,h;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
image=findViewById(R.id.image_id);
paint=new Paint();
paint1=new Paint();
paint2=new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
paint.setColor(Color.WHITE);
paint1.setStyle(Paint.Style.STROKE);
paint1.setStrokeWidth(3);
paint1.setColor(Color.RED);
paint2.setStyle(Paint.Style.STROKE);
paint2.setStrokeWidth(3);
paint2.setColor(Color.BLUE);
bitmap=Bitmap.createBitmap(getWindowManager().getDefaultDisplay().getWidth(),getWindowManager().getDefaultDisplay().getHeight(),Bitmap.Config.ARGB_8888);
canvas=new Canvas(bitmap);
image.setImageBitmap(bitmap);
w=getWindowManager().getDefaultDisplay().getWidth();
h=getWindowManager().getDefaultDisplay().getHeight();
handler=new Handler(getMainLooper());
runnable=new Runnable() {
@Override
public void run() {
if(i<=w/2){
canvas.drawCircle(w/2,h/4,i,paint1);
canvas.drawCircle(w/2,h*3/4,i,paint2);
i+=20;
j=w/2;
}
else if(i>w/2){
canvas.drawCircle(w/2,h/4,j,paint);
canvas.drawCircle(w/2,h*3/4,j,paint);
j-=20;
if(j==0)
i=0;
}
handler.postDelayed(runnable,5);
image.invalidate();
}
};
handler.postDelayed(runnable,100);
}
}
Run the application :
To run the app on your phone, connect your phone to the computer via USB cable (data cable). To run the project, click on the green “Run” button in the Android Studio IDE. When the app will be installed and launch on your device, you can see below image as output.

Conclusion :
After completing the article, you have learned how to build graphics applications using android studio IDE. Now, you can build more complex graphics application with advanced features and design patterns as you like. Thank you for visiting my site.