Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active July 10, 2018 15:13
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 alexfu/c8c0fa13a2b51738665c82cca412b5b5 to your computer and use it in GitHub Desktop.
Save alexfu/c8c0fa13a2b51738665c82cca412b5b5 to your computer and use it in GitHub Desktop.
Stretched LayerDrawable with centered icon
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:layout_width="200dp"
android:layout_height="100dp"
android:src="@drawable/sample"
android:scaleType="fitXY"/>
</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorAccent"/>
<item android:drawable="@drawable/ic_android_black_24dp" android:gravity="center"/>
</layer-list>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment