Rounded Corners and Borders in Android Studio

I want to add rounded corners and borders to a textview. But only the top corners should be rounded and the bottom should be without border. Already found this:

But then I have rounded corners at the bottom too.

How can I change this?

Create a drawable file like this :

    <?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android=""

    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />
        <stroke android:width="4dp" android:color="#000000" />
        <corners android:radius="4dp" />


And then apply it as an background of any control and there you go, it's done.

How to make layout with rounded corners..?, This in-built feature makes rounded corners very easy to implement. instead of android:background (since background is used for the rounded shape). a drawable with a white background, black border and rounded corners: It allows customizing the rounded corners, stroke color and width, and elevation. Example: If you want to add rounded corner to any kind of android view like linear layout, relative layout, button etc., follow the below method Method 1 Create a xml file under your drawable folder with following code. (The name of the file I created is rounded_corner.xml)

With the Material Components Library you can use the MaterialShapeDrawable to draw custom shapes.

With a TextView you can do:


Then create a MaterialShapeDrawable. Something like:

    TextView textview = findViewById(;
    ShapeAppearanceModel shapeAppearanceModel = new ShapeAppearanceModel()
    MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
    shapeDrawable.setStroke(2.0f, ContextCompat.getColor(this,R.color.xxxx));

How to create a layout with rounded corner borders in Android , In Android, when you define your user interface in XML, you can define a border for layouts Duration: 9:19 Posted: Nov 24, 2015 Rounded Corners. In this quick article we will see how to add Rounded corners to Views and Layouts. This can be done on Layout XML or Programatically. Here we will see both the ways. Rounded Border with Transparent Inside. Create an xml inside Drawable Folder with below code. Name it rounded_red_border.xml

Create Draweable rounded_border.xml

<shape xmlns:android=""
        android:top="3dp" />

        android:color="#FFFFFF" />

        android:radius="5dp" />

        android:height="110dp" />

Then Set this Drawable in view's background property

    android:textSize="15sp" />

Also helpful this solution to you: Click Me

Hope this may help you

Add Rounded Corners to Views and Layouts Android, Rounded Border with Transparent Inside. Rounded Corners. Create an xml inside Drawable Folder with below code. Name it� If you're just looking to create a shape that rounds the corners, removing the padding and the stroke will do. If you remove the solid as well you will, in effect, have created rounded corners on a transparent background. For the sake of being lazy I have created a shape underneath, which is just a solid white background with rounded corners - enjoy!

Rounded Corner in Android Studio || material design, Enjoy the videos and music you love, upload original content, and share it all with friends, family Duration: 6:56 Posted: Feb 13, 2018 In this tutorial we will see how to make a Button with rounded corners. In some applications we can see the button with rounded corners and borders.Android is not providing any default Button widget with rounded corners , but we can achieve this by setting a drawable background for the default Button in android.

Android TextView With Rounded Corner and Border, It needs to ripple, have rounded corners… oh, and three borders… <ripple xmlns:android="" Add rounded corners border to TextView using xml Android.Creating textView with rounded border using external layout xml file.corners android:radius="20dp".

Creating a Ripple Drawable with Bordered, Rounded Edges, In this Android tutorial, we'll create rounded corners with a stroke -- or border. The finished Built with Android Studio and Kotlin. updated 11� To make the border, you need the stroke tag. You can select a color and width of the border with the stroke tag. To use it use the border drawable for the background attribute. Dashed border for a button that changes on click

  • add your code segment for more understand of your question
  • Checkout this solution :
  • The corners are perfect, thanks! But how can I add the border?
  • But then the border is at the tottom too
  • What do you want to achieve? Please upload photo of that
  • I want the border to be at the left, right and top. The bottom should be borderless
  • The borders are correct now. Combined with <corners android:topLeftRadius="5dp" android:topRightRadius="5dp"/> it's perfect!