0
votes

I have an android activity that has an image overlaying a background image. The 2 images must line up(height only), so the height of the background image must not be scaled. However, on wide displays, i need to stretch the width of this background to fit the screen. Currently I have set the Activity background like this.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layRoot"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/meditation_bg">

meditation_bg is a drawable resource. the code is

<?xml version="1.0" encoding="utf-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/morn_blur_bg"
    android:gravity="top|center"
    android:scaleType="centerCrop"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />

The bitmap drawable resource is required to prevent the OS from scaling the image for me.

How can I control the width, without affecting the height of the image.

cheers,

1
i don't really understand what you actually need to achieve...pskink
Hi, I need to stretch a background images width, without affecting the height. Height must stay the same.Rival

1 Answers

0
votes

I'd highly recommend taking a look into Picasso, They provide image caching, adjusting much much more easier.