I create simple example. Take a look
It's a simple layout
LinearLayout with children
- Relative - bg = test_drawable_1
- Relative - bg = test_drawable_2
- Relative - bg = test_drawable_3
- Relative - bg = test_drawable_4
- Relative - bg = test_drawable_5
Each test_drawable it's a drawable xml file with layer-list root element and shapes. Each number it's a count of shapes
With more layers of shapes overdraw will grow
Layout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/test_drawable_1"
android:layout_marginBottom="8dp"></RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/test_drawable_2"
android:layout_marginBottom="8dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/test_drawable_3"
android:layout_marginBottom="8dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/test_drawable_4"
android:layout_marginBottom="8dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/test_drawable_5"
android:layout_marginBottom="8dp" />
</LinearLayout>
test_drawable_1
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="@dimen/gs_GridSize2x" />
<padding android:top="1dp" android:right="1dp" android:left="1dp" android:bottom="1dp"/>
<solid android:color="#95C4CF"/>
</shape>
</item>
</layer-list>
Is exists any way to reduce GPU overdraw with drawable layer-list xml?