how to edit border radius in TextView in .net android?

mc 5,426 Reputation points
2024-05-21T05:30:44.6833333+00:00

how to edit one corner radius (border radius) in TextView or LinearLayout?

in activity_main.xml

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"

android:background="#5663ff" android:textColor="#ffffff" />

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-05-21T07:40:36.94+00:00

    Hello,

    Please Create drawable folder in Resources folder, then create a xml file called rounded_corner.xml in the drawable folder and add the following content. <stroke> is set border color and width.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >         
       <stroke
           android:width="3dp"
           android:color="#ff00000" />
    
       <solid android:color="#ffffff" />
    
       <padding
            android:left="1dp"
            android:right="1dp"
            android:bottom="1dp"
            android:top="1dp" />
    
       <corners android:radius="5dp" />
    </shape>
    

    Set this drawable in the TextView or LinearLayout background property .

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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:background="@drawable/rounded_corner"
    
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
    
            android:background="@drawable/rounded_corner"
    
            android:text="@string/app_text"
        />
    </LinearLayout>
    
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.