Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active Jul 10, 2018
Embed
What would you like to do?
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