Reputation: 7759
Android's ViewOverlay
allows easy overlaying of Drawable
s over a conventional view element without having to interfere with the layout, but it is only available since API 18 (and as far as I can see, there's no compatibility layer, that backports this).
What would be the easiest alternative for an older API level (specifically: 15) to overlay a Drawable
over a view element without modifying the layout? In my case, it would be enough to deal with a single Drawable
; I don't need to replicate support for multiple Drawable
s that the new overlay API allows.
Upvotes: 0
Views: 880
Reputation: 6010
Did you try FrameLayout
's foreground attribute?
FrameLayout
's foreground is drawn over it's contents. And this works with API level 15.
In your xml:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/your_drawable">
...
Your contents.
...
</FrameLayout>
Or in your source code:
frameLayout.setForeground(drawable);
Upvotes: 2