An easy way to do this is to use a 9-patch image . For example, if you want to reproduce the double-window effect with Theme.DeviceDefault.Light (API> 14), use the Selector to apply a background image with 9 patches in the selected state of your LinearLayout element.
An example of selecting the layout of an element:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="48dp" android:background="@drawable/activable_indicator_background" android:gravity="center_vertical" android:paddingRight="20dp"> //eventually other items... </LinearLayout>
Drawable/activable_indicator_background.xml :
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_activated="true" android:drawable="@drawable/indicator" /> <item android:drawable="@android:color/transparent" /> </selector>
Drawable/indicator.9.png :

source share