Skip to content

Instantly share code, notes, and snippets.

@kevivforever
Created May 3, 2019 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevivforever/827bb92677f0cc9b7fc8ebab65193422 to your computer and use it in GitHub Desktop.
Save kevivforever/827bb92677f0cc9b7fc8ebab65193422 to your computer and use it in GitHub Desktop.
Different xml drawables backgrounds
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/colorGreyIcon"/>
<size
android:width="60dp"
android:height="60dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<!--<corners android:radius="4dp"/>-->
<gradient
android:type="linear"
android:endColor="#78ffd6"
android:startColor="#007991" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorBorder" />
</shape>
</item>
<item android:right="1dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorBackground" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="?android:colorControlHighlight"
tools:targetApi="lollipop">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="?android:colorAccent" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorGreyIcon" />
</shape>
</item>
</ripple>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/colorBorder"/>
<corners android:radius="2dp"/>
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#E0E0E0" />
<corners android:radius="2dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/cardview_dark_background"/>
<corners android:radius="2dp"/>
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/colorBorder"/>
<corners android:radius="2dp"/>
</shape>
</item>
</selector>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment