ExtraTextView In Android Using Android Studio

Introduction

 
In this article, we are going to create an ExtraTextView in Android using Android Studio. It is a type of library that makes the image into an icon for text. By using this, we can render the image to text. This View is widely used in web pages.
 
Step 1
 
Create a new project in Android Studio.
 
 
 
Give a name to the project and click "Next".

 
Select the "Phone and Tablet" option and click "Next".
 
 
Select an empty activity and click "Next".
 
 
At last, give the activity name and click on "Finish".
 
 
 
Step 2
 
Next, copy the source image in .png format.
 
 
Locate app>>res>>drawable folder and paste the copied image into the drawable folder.
 
 
Check whether it is pasted correctly.
 
 
Step 3
 
Locate the Gradle Scripts>>Build. Gradle 1.
 
 
 
And, type the following dependency in your app's build.gradle.
 
 
Then, click the sync button in the top right corner and repeat this for step 4.
 
 
Code copy is here
  1. maven { url "https://jitpack.io" }  
Step 4
 
Locate the Gradle Scripts>>Build. Gradle 2.
 
 
Type the following dependency in your app's build.gradle.
 
 
The code copy is here.
  1. compile 'com.github.chuross:extra-textview:1.1.3'  
Step 5
 
Next, go to app >> res >> layout >> activity_main.xml. Select activity page.
 
 
Just type the code as below.
 
 
The code copy is here.
  1. <com.github.chuross.widget.ExtraTextView  
  2.     android:layout_width="wrap_content"  
  3.     android:layout_height="wrap_content"  
  4.     android:layout_centerHorizontal="true"  
  5.     android:layout_centerVertical="true"  
  6.     android:gravity="center"  
  7.     android:padding="20dp"  
  8.     android:text=" C# Corner MVP"  
  9.     android:textSize="32sp"  
  10.     app:ext_txt_cornerBackgroundColor="@color/colorAccent"  
  11.     app:ext_txt_cornerBorderColor="#000"  
  12.     app:ext_txt_cornerBorderSize="4dp"  
  13.     app:ext_txt_cornerRadius="2sp"  
  14.     app:ext_txt_drawable="@drawable/sa"  
  15.     app:ext_txt_drawableHeight="60dp"  
  16.     app:ext_txt_drawablePosition="left"  
  17.     app:ext_txt_drawableWidth="60dp" />  
Step 6
 
Next, go to app >> java>>Mainactivity.java. Select Mainactivity page.
 
 
And check whether it is the default.
 
 
Step 7
 
Verify the preview.
After the code is applied, the preview will appear like this.
 
 
Step 8
 
Next, go to Studio and deploy the application. Select an Emulator or your mobile with USB debugging is enabled. Give it a few seconds to make installations and set permissions.
 
 
Run the application in your desired emulator (Shift + F10).
 
 
Explanation of source code
 
The source code used in the activitymain.xml file will insert the image into the app and render the image to the Text given. This given source code will work behind the Gradle dependency.
 

Summary

 
We have just created the app to see how the ExtraTextView works and learned where to use it.
 
*Support and Share; Thank you*


Similar Articles