Search code examples
androidxmlandroid-linearlayout

Rounded linear layout leaving extra space on corners


i am creating a rounded linear layout with some buttons and textviews, i have used a custom selector as background of layout. My problem is that layout have extra space on corners how to remove this? any help will be appreciated here is my code

<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp"
    >
    <solid android:color="#FFFFFF"/>
    <corners
        android:bottomRightRadius="15dp"
        android:bottomLeftRadius="15dp"
        android:topLeftRadius="15dp"
        android:topRightRadius="15dp"
        />
    <stroke android:width="2dip"
            android:color="@color/#275D69"/>
</shape>

Layout:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/selector"
    />

Current output: enter image description here

Dont want that space where i have placed red marks.


Solution

  • With below code you have rounded background with least space on corner

     <?xml version="1.0" encoding="utf-8"?>
       <shape xmlns:android="http://schemas.android.com/apk/res/android"
          android:padding="10dp"
          android:shape="rectangle">
        <solid android:color="#FFFFFF" />
        <corners android:radius="5dp" />
        <stroke
          android:width="2dip"
          android:color="#275D69" />
       </shape>
    

    this may include space on corner but it's too low.

    just reduce radius value.