I'm trying to create a background drawable made of a gradient that fills the entire view and a pattern with left gravity that resizes to fit vertically while keeping its aspect ratio.
This is what I currently have:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/myGradient"/>
<item>
<bitmap android:src="@drawable/myPattern"
android:gravity="left" />
</item>
</layer-list>
Both drawables are VectorDrawables.
This is meant to be the background of a wrap_content
height view.
This does not resize the pattern, but rather centers it vertically. If I set the gravity to fill_vertical
, it only resizes in that axis and the aspect ratio breaks.
Is there any way to achieve this in XML without using ImageViews or other layouts? Can it be done programatically? Or do I require a different layout?