I already have shape code and now I need to draw the same programmatically and set its width according to the length of texts in an array. I am not able to reproduce the same using path data.
This is the code:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="2778"
android:viewportHeight="1250"
android:width="250.0002dp"
android:height="112.5dp">
<path
android:pathData="M2764 1250L0 1250 0 0l2256 0 4 4 513 468 4 4 0 774 -14 0 0 0zm-2737 -27l2723 0 0 -736L2245 26 27 26 27 1222Z"
android:fillColor="#FF6E00" />
</vector>
Please help me on this..
Method 1: By Creating custom shape:
How to use this programmatically:
Output for above code is:
Method 2: By Using Material Shape Drawable:
Add this dependency into build.gradle(app) file:
implementation 'com.google.android.material:material:1.3.0'How to use:
Output for above code is: