Mohit Dholakia
Mohit Dholakia

Reputation: 252

How to create layout having top Left and Right Round Corners in android?

I need to create layout which has top left and right corners have rounded corner also i have tried by drawable radios but i have imageview which is inside my parent layout so thats why i am not getting my desired shape.

Can anyone help me to achieve this kind of UI

Upvotes: 0

Views: 1928

Answers (4)

Ahmed Jamal
Ahmed Jamal

Reputation: 201

You can Create Drawable resourse with radius at top left and top right an set it as background to the layout or you can use this library https://github.com/florent37/ShapeOfView

Upvotes: 2

Subhasmith Thapa
Subhasmith Thapa

Reputation: 894

This is what you can possibly use . For your desired colour use different colour you want. Use this only for the layouts where you want rounded corners and not on the parent layout


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@android:color/transparent" />
    <stroke
        android:width="1dp"
        android:color="@android:color/white" />
    <corners android:radius="15dp" />
    <padding
        android:bottom="5dp"
        android:left="10dp"
        android:right=10dp"
        android:top="5dp" />
</shape>

Upvotes: 0

Niroop Nife
Niroop Nife

Reputation: 376

Have you tried adding by creating a new drawable resource file?

    <?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- view background color -->
    <solid
        android:color="#a9c5ac" >
    </solid>

    <!-- view border color and width -->
    <stroke
        android:width="3dp"
        android:color="#1c1b20" >
    </stroke>

    <!-- If you want to add some padding -->
    <padding
        android:left="4dp"
        android:top="4dp"
        android:right="4dp"
        android:bottom="4dp"    >
    </padding>

    <!-- Here is the corner radius -->
    <corners
        android:radius="10dp"   >
    </corners>

</shape>

Add this in your required layout file

Upvotes: 0

Md. Nowshad Hasan
Md. Nowshad Hasan

Reputation: 626

Try this :

<corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
         android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>

as drawable. Source - Android - drawable with rounded corners at the top only

Upvotes: 0

Related Questions