I have an activity, I’ll call it mainactivity for now. And I want to know how to put a background onto it. I know how to add the background by adding android:background="@drawables/background"
But I want to align it to the bottom right (Gravity) and keeps it’s original ratio because the background tag is stretching it
This is what I have got so far. A styles.xml file and the background tag on the linear layout set to @style/Background
Styles file:
<style name="Background">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/background"
android:gravity="bottom|right"
/>
</style>
What do I add/change (or anything else I could do) to make the drawable ‘lock’ to the bottom right corner?
Thanks
You can create a new bitmap drawable that specifies a source drawable and a gravity, then use that drawable as background.
For instance, create a new bitmap drawable named
aligned_background.xml:and then set your background to
@drawable/aligned_background.