I have one image which i need to set as device wallpaper from drawable folder.
I created one demo application in which oncreate of activity i just wrote code for set wallpaper of device as that particular image.
But when I set this image as wallpaper its either zoom or cropped. I want image should fit on screen size. In some devices it works in some it does not.
Moreover when i rotate my device at that time also wallpaper gone or some part of that cropped.
I have image resolution is 600*1024 pixels. I have samsung galaxy tab 2 that is also have same Size 600 x 1024 pixels, 7.0 inches (~170 ppi pixel density).
But its not working. Please help me to sort out this issue.
Thanks
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>
permission in manifest
Related
I have implemented a splash screen in android with a full image background using a drawable resource. This displays correctly on traditional screen aspect ratios. When I now run it in Samsung Galaxy S8 which has an aspect ratio of 18:9, the background image get's stretched vertically.
I shy away from using a layout as my splash screen as there will be a delay for the image to show up.
One thing I can think of is if we have a specific image sized for 18:9 but then how can I make it so that android will pick that specific image based on certain aspect ratio?
Use screen aspect qualifier and make a different layout for long screen devices and Android will detect it.
This is not a perfect answer but it works in situation where you don't care about little bit cropping of image, add
android:scaleType="centerCrop"
in imageview tag of splash xml.
I'm using the approach described in Creating a Splash Screen. It uses a resource (layer-list) with a background and an image. That is used as windowBackground in a theme and this theme is set on an activity. Now I created all drawable folders and put images of different sizes in there.
Now I have these issues:
starting app in landscape on smart phone leads to a black splash screen (on tablet it stays in portrait)
images from drawable-land folder are not taken
the size of the image should be bigger on some devices
In which resolution should I provide the images? The image should have one third of the width of the display width. How can I manage that?
I tried to use this table as reference and calculating the width by taking one third of portrait size. E.g for HDPI, one third of 480 is 144, but the tablet has a width of 800 (not 480). As consequence the image is too small.
Furthermore I don't think that 9-patch files could help me here. It only describes the enlargement, but then the lowest common denominator would be an image of size LDPI ... Enlargement doesn't work so good for a text logo (custom font).
What are my options?
Edit:
starting app in landscape on smart phone leads to a black splash screen (on tablet it stays in portrait):
Adding a break point and the splash screen is shown instead of a black screen. Building an apk and installing on the smartphones works. Debug mode not.
images from drawable-land folder are not taken
Added ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation) and now they are.
But I still have no clue how to define an image, which does take a certain amount on the screen with this approach. For now I supplied a bigger image (xhdpi into hdpi) ...
you should put those images in mipmap folder not at drawable. You have to crop image into three size hpdi,ldpi and mdpi. These theree are best for any android devices.(Fits for all). If you want to display image in full screen then you can define android:background="#mipmap/image" instead of android:windowBackground="#mipmap/image" . For preventing splahscreen from being landscape you can define screen orientation inside activity like below:
<activity android:name=".Splash_Screen"
android:screenOrientation="portrait">
If you doesn't know the required resolution for image ldi,hdpi and mdpi then there's question asked on stackoverflow, google it!! Hope it helped and sorry for poor english!!
I am new to android development and now i have started developing wallpaper apps.I saw the android developer page which tells the ratio 3:4:6 or something which i don't understand. Everything is working but the image which i set go off the screen sometimes it gets cropped around the corners and image does not look good. i use the screen size 600*480 in hdpi. Any suggestion about the different size images i should use may be for ldpi,mdpi,hdpi, xhdpi.I want my wallpaper look good in home screens of both tablets and for large size screen mobiles.
Thank You.
3:4:6:8 , so if you have 600*480 in hdpi then it should go like this
3k:300*240
4k:400*320
6k:600*480
8k:800*640
but since there are multiple device with same dp but different screen size, you can never quitly fit for every device
Right now, i am developing Android Application using SDK 1.5 and testing application on HTC Hero, its firmware is Android 1.5.
Let me come to actual point: in application, i am having an imageview for displaying image (Image resolution is 320*480), now imageview is displaying image in full-screen perfectly, but when i am trying to test it on HTC EVO 4G (having resolution 480*800), image gets stretch.
So, what i like to do is want to display 320*480 resolution image in all screen-resolution mobile ? i means to say,if the mobile is of higher resolution(i.e. 480*800 , 480*854, or else) than the image should be displayed in "Center" portion of the screen.
So displaying image in Center in all screen (without stretching or cutting) resolution other than 320*480, what attributes i have to set ?
Simply set the scaleType attribute of your ImageView. Possible values here: ImageView.ScaleType You might want to use CENTER.
In addition you face another problem: You have to provide a hdpi image in addition to your mdpi image so your mdpi image does not get automatically scaled up to hdpi by the Android system, read more here: http://developer.android.com/guide/topics/resources/providing-resources.html
Edit: Oh, and I nearly forgot: The 'drawable-mdpi' and 'drawable-hdpi' folders are only possible if you build your project against at least Android 1.6. So you have to set your minSdkVersion to 3 and your targetSdkVersion to 4, and place your images into the normal 'drawable' folder in order for Android 1.5 to catch up. See this video from the Google I/O 2010 to learn more: Casting a wide net for all Android devices.
Which are the default dimension of the Home wallpaper/background for the various Android screen configurations (small, normal and large screens with low, medium and high density)?
Are 9-patch PNG files supported for the wallpaper? Should I be using these instead?
I found a method in API level 5 that gives you the minimum size of the wallpaper, but I would like to support previous versions of Android as well.
Thanks!
A wallpaper is twice as wide as the device held in portrait mode. So 960x800 on a Nexus One, 960x854 on a Droid, 640x480 on a G1/Magic/Hero, etc.
This article on the Android Developers' site shows the range of screen resolutions for each density.
I believe the wallpapers have to match the screen resolution and are not stretched. You can see this if, for example, you create a new emulator with a high screen density like 480x854. The default home screen background is centred, with large black bands at the top and bottom.
The WallpaperManager API indicates that you must use a PNG- or JPEG-format image, even if you use the setResource() method — the resource must be a Bitmap and so not a nine-patch or other type of Drawable.
Don't guess, ask the WallpaperManager:
manager = WallpaperManager.getInstance(this);
width = manager.getDesiredMinimumWidth();
height = manager.getDesiredMinimumHeight();