Introduction

In the current scenario, most people use Android smartphones. I will show you how to change GUI components in an Android, using Android Studio. Android is the kernel based operating system. It allows the user to modify GUI components and the source code.
Requirements

Steps to be followed are given below

Carefully follow the steps given below to learn how to change GUI components in an Android and I have included the source code given below.
Step 1
Open Android Studio. Start the new project.
android
Step 2
Put the Application name and company domain. If you wish to use C++ to code the project, mark the Include C++ support, followed by clicking Next.
android
Step 3
Select Android minimum SDK. Afterwards, you chose the minimum SDK and it will show the approximate percentage of people who use SDK , followed by clicking Next.
android
Step 4
Choose the basic activity, followed by clicking Next.
android
Step 5
Put the activity name and layout name. Android Studio basically takes Java class name from what you provide as the activity name.
android
Step 6
This is the default activity design for the basic activity layout.
android
Step 7
Go to activity_design.xml then click the text bottom.
android
Step 8
Into the activity_design.xml, copy and paste the code given below.
activity_design.xml code
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent" android:layout_height="fill_parent"
  4. android:orientation="vertical" >
  5. <TextView
  6. android:id="@+id/textView1"
  7. android:layout_width="match_parent"
  8. android:layout_height="wrap_content"
  9. android:layout_margin="20sp"
  10. android:gravity="center"
  11. android:text="DESIGN ANDROID"
  12. android:textSize="20sp"
  13. android:textStyle="italic" ></TextView>
  14. <Button
  15. android:id="@+id/button1"
  16. android:layout_width="match_parent"
  17. android:layout_height="wrap_content"
  18. android:gravity="center"
  19. android:text="Change font size"
  20. android:textSize="20sp" />
  21. <Button
  22. android:id="@+id/button2"
  23. android:layout_width="match_parent"
  24. android:layout_height="wrap_content"
  25. android:gravity="center"
  26. android:text="Change color"
  27. android:textSize="20sp" />
  28. <Button
  29. android:id="@+id/button3"
  30. android:layout_width="match_parent"
  31. android:layout_height="wrap_content"
  32. android:gravity="center"
  33. android:text="Change font"
  34. android:textSize="20sp" />
  35. </LinearLayout>
android
Step 9
This is our user interface of the Application
android
Step 10
Into the DesignActivity.java, copy and paste the code given below. Do not replace your package name.
DesignActivity.java code
  1. package ganeshannt.designandroid;
  2. //import android.R;
  3. import android.app.Activity;
  4. import android.graphics.Color;
  5. import android.graphics.Typeface;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.TextView;
  10. public class DesignActivity extends Activity
  11. {
  12. float font =24;
  13. int i=1;
  14. @Override
  15. public void onCreate(Bundle savedInstanceState)
  16. {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_design);
  19. final TextView t1=(TextView) findViewById(R.id.textView1);
  20. Button b1 = (Button) findViewById(R.id.button1);
  21. b1.setOnClickListener(new View.OnClickListener()
  22. {
  23. public void onClick(View view)
  24. {
  25. t1.setTextSize(font);
  26. font=font+4;
  27. if(font==40)
  28. font=20;
  29. }
  30. });
  31. Button b2 = (Button) findViewById(R.id.button2);
  32. b2.setOnClickListener(new View.OnClickListener()
  33. {
  34. public void onClick(View view)
  35. {
  36. switch(i)
  37. {
  38. case 1:
  39. t1.setTextColor(Color.parseColor("#0000FF"));
  40. break;
  41. case 2:
  42. t1.setTextColor(Color.parseColor("#00FF00"));
  43. break;
  44. case 3:
  45. t1.setTextColor(Color.parseColor("#FF0000"));
  46. break;
  47. case 4:
  48. t1.setTextColor(Color.parseColor("#800000"));
  49. break;
  50. }
  51. i++;
  52. if(i==5)
  53. i=1;
  54. }
  55. });
  56. }
  57. }
android
Step 11
Click Build bottom and make the project. Now, your project compilation process is going on. Any error found in your project will be shown to you.
android
Step 12
Click run botton. Your emulator will start, followed by running your Application.
android
Deliverables
Proceed as shown.
android
android
android
android
If you have any doubts, just comment below.