Gautham Nadar
Gautham Nadar

Reputation: 55

Android - Curve Corner in specific angle

Is there any way to curve corner radius of a rectangle in specific degree, Like this Image https://i.sstatic.net/nMhQL.jpg

Upvotes: 0

Views: 885

Answers (2)

ViduraPrasangana
ViduraPrasangana

Reputation: 897

I think there is not proper way to create rectangles with specific degree. But you can draw a shape like this from photoshop and use that as your backgruond.

Photoshop:

  • Draw a Rectangle
  • Add a radius using properties
  • Use Free Transform option and drag corner with pressing left-ctrl
  • Export image as SVG file

Android Studio:

  • Import image as vector asset

Edit: I designed your background. Create a xml file in drawable folder and past this code

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="496dp"
    android:height="701.6dp"
    android:viewportWidth="2480"
    android:viewportHeight="3508">
  <path
      android:fillColor="#ffffff"
      android:pathData="M665,491H1868c163.95,0 230,93.38 230,276V1974.34c0,181.63 -143.4,268.71 -308.25,193.55l-1165.7,-531.42C551.45,1603.37 498,1488 498,1379V691C498,581.54 592.7,491 665,491Z"
      android:strokeLineJoin="round"
      android:strokeWidth="0"
      android:fillType="evenOdd"
      android:strokeColor="#fff200"
      android:strokeLineCap="round"/>
  <path
      android:fillColor="#ffffff"
      android:pathData="M714,1890l1241,535c119.88,57.69 140,98.78 140,178v123c0,123.09 -125.48,146 -158,146H791c-181.54,0 -293,-27.95 -293,-243V2056C498,1841.29 648.54,1851.85 714,1890Z"
      android:strokeLineJoin="round"
      android:strokeWidth="0"
      android:fillType="evenOdd"
      android:strokeColor="#fff200"
      android:strokeLineCap="round"/>
</vector>

Upvotes: 1

Hamza Khan
Hamza Khan

Reputation: 1521

You can create a Vector drawable, but you need to understand SVG xml language to do this, It's better to use photoshop PNG file for the background image (as every view in android is a rectangle.

Sample vector drawable xml.

 <vector android:height="24dp" android:tint="#FFFFFF"
    android:viewportHeight="24.0" android:viewportWidth="24.0"
    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FF000000" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
</vector>

Upvotes: 0

Related Questions