How to Add a TextView with Rounded Corner in Android? Last Updated : 18 Feb, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report TextView is an essential object of an Android application. It comes in the list of some basic objects of android and used to print text on the screen. In order to create better apps, we should learn that how can we create a TextView which have a background with rounded corners. We can implement this skill in a practical manner for any android application. For creating professional-looking user interfaces, we need to take care of these small things. In this article, You will be learning how to create a TextView with Rounded Corners. First of all, we need to create a drawable resource file, which has a proper definition to make TextView corners rounded, and then we have to add a background attribute to that special TextView object. Let's do it in steps! Step by Step Implementation Step 1: Create a new android studio project, and select an empty activity. You can also refer to this GFG Tutorial for Creating a new android studio project. Step 2: Make sure that you have selected the Android option for project structure on the top left corner of the screen, then go to the res/drawable folder. Step 3: Here right-click on the drawable folder and click on new and select drawable resource file. Give it a name of your choice, we are giving it rounded_corner_view. Note: In android studio you can't give a name of a resource file (Layout file, Color File, Image File, or any XML file) in uppercase and camelCase, you have to follow the lowercase letters only and it's a good habit to use lowercase letters with underscores in place of spaces. Step 4: Now in the drawable resource file, which you have just created, remove all the default code and paste the following code. XML <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp" /> <!-- This is the border color --> <stroke android:width="2dp" android:color="#ccc" /> <!--- This is the background color --> <solid android:color="#ccc" /> </shape> Step 5: Now go to the activity_main.xml file and add an attribute to that TextView, for which you want to add rounded corners. The attribute is android: background="@drawable/rounded_corner_view". Tip: Don't forget to replace your drawable resource file name if you have given a different name and you don't need to add xml extension after file name. Output UI: Comment More infoAdvertise with us Next Article How to Add a TextView with Rounded Corner in Android? E encrypter09 Follow Improve Article Tags : Android Android-View Similar Reads Android Architecture Android architecture contains a different number of components to support any Android device's needs. Android software contains an open-source Linux Kernel having a collection of a number of C/C++ libraries which are exposed through application framework services. Among all the components Linux Kern 5 min read Android Tutorial In this Android Tutorial, we cover both basic and advanced concepts. So whether you are a fresher (graduate) or an experienced candidate with several years of Android Development experience, you can follow this Android tutorial to kick-start your journey in Android app development. Our Android Tutor 15+ min read Activity Lifecycle in Android with Demo App In Android, an activity is referred to as one screen in an application. It is very similar to a single window of any desktop application. An Android app consists of one or more screens or activities. Each activity goes through various stages or a lifecycle and is managed by activity stacks. So when 9 min read Introduction to Android Development Android operating system is the largest installed base among various mobile platforms across the globe. Hundreds of millions of mobile devices are powered by Android in more than 190 countries of the world. It conquered around 71% of the global market share by the end of 2021, and this trend is grow 5 min read Top 50 Android Interview Questions and Answers - SDE I to SDE III A Linux-based open-source OS, Android was created by Andy Rubin and became one of the most popular smartphone operating systems. With 71 percent of the market share worldwide, Android is on top. Because it is on top in the smartphone OS, Android development is always in demand.If you are seeking a j 15+ min read Android UI Layouts Layouts in Android define the user interface and hold UI controls or widgets that appear on the screen of an application. Every Android application consists of View and ViewGroup elements. Since an application contains multiple activitiesâeach representing a separate screenâevery activity has multip 5 min read Components of an Android Application There are some necessary building blocks that an Android application consists of. These loosely coupled components are bound by the application manifest file which contains the description of each component and how they interact. The manifest file also contains the appâs metadata, its hardware confi 3 min read Android Studio Tutorial It is stated that "If you give me six hours to chop down a tree then I will spend the first four hours in sharpening the axe". So in the Android Development World if we consider Android Development as the tree then Android Studio should be the axe. Yes, if you are starting Android Development then y 9 min read MVVM (Model View ViewModel) Architecture Pattern in Android Developers always prefer clean and structured code for projects. Organizing the codes according to a design pattern helps in the maintenance of the software. By having knowledge of all crucial logic parts of the android application, it is easier to add and remove app features. Further, design patter 8 min read What is Intent in Android? In Android, it is quite usual for users to witness a jump from one application to another as a part of the whole process, for example, searching for a location on the browser and witnessing a direct jump into Google Maps or receiving payment links in Messages Application (SMS) and on clicking jumpin 4 min read Like