0

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

Subhasmith Thapa
  • 884
  • 7
  • 11
Mohit Dholakia
  • 252
  • 2
  • 16

4 Answers4

2

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

Ahmed Jamal
  • 216
  • 1
  • 5
0

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

  • 1
    Thanks for your time but i am having imageview and other component inside this layout that's why imageview is overlapping this kind of drawable – Mohit Dholakia Mar 05 '19 at 07:05
0

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

hakamairi
  • 4,464
  • 4
  • 30
  • 53
Niroop Nife
  • 356
  • 1
  • 5
  • 18
  • Consider i am having two layout parent has this background which is provided by you and other is child which has imageview.In this case i am not getting rounded corner on imageview – Mohit Dholakia Mar 04 '19 at 17:16
0

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>

Subhasmith Thapa
  • 884
  • 7
  • 11