How to create this shape programmatically?
<?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="#e67e22"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
</shape>
I've tried this simple function which gets corners, colors and sets that to shape:
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.category_header);
GradientDrawable drawable = (GradientDrawable) linearLayout.getDrawable();
float[] values = { 0.2f, 0.2f, 0.2f, 0.2f };
drawable.setCornerRadii(values);
But I got this error:
The method getDrawable() is undefined for the type LinearLayout