0

I have a custom .png image set as my Android device's wallpaper.

As I understand it, wallpaper size should be 960x800 pixels but the Android device will only present the middle part of the image and the extra right and left parts are for when you scroll right and left on the screen. So I’ve taken a small image that I want it to be in the center of the screen (350x350) and filled the rest of the image with a black surrounding.

My problem is: I have an activity in my application that needs its background to be similar to the wallpaper (to imitate a blank activity with just a TextView presented on it). I’m using this code to do so:

private WallpaperManager wallpaperManager;
private Drawable wallpaperDrawable;
private RelativeLayout rtemp;

rtemp = (RelativeLayout)findViewById(R.id.temp_layout);
wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
rtemp.setBackground(wallpaperDrawable);

But the screen appears to have the wallpaper as a whole and not just the middle part anymore (it basically shrink down the image) and it is not consistent with the regular wallpaper anymore.

Are there any suggestions on how to solve it? Is there a way to avoid image shrinking on the activity or is there a way to make the image not spread as the wallpaper screen?

Thanx a lot!

1 Answers1

0

Better use FrameLayout which contains both your RelativeLayout over an ImageView. Imageview gives you the options to scale your image & some furthermore customization.

Aakash Kumar
  • 1,069
  • 7
  • 11
  • But wouldn't it still scale down the wallpaper image to fit to the screen? while the actual wallpaper is much wider... – FarFarAwayUser Dec 16 '14 at 16:05
  • Its not, if you are using it with the correct scaletype & you can customize the imageview without being worried about your app's layout. See this http://developer.android.com/reference/android/widget/ImageView.ScaleType.html – Aakash Kumar Dec 16 '14 at 16:14
  • I am not asking any clarification from anyone. I am just posting the answer which I think can resolve his problem. – Aakash Kumar Dec 16 '14 at 16:36