How to center crop splash screen using windowBackground attribute in Android - java

Graphic designer who I work with provided full-screen splash screen image. I was asked to use it in a way, that it works as if it was ImageView with scaleType set to centerCrop. I also was asked to show this image immedietely when app starts.
So, I tried to set application splash screen via windowBackground attribute, but it's stretched as if scaletype was fitXY (in ImageView terminology). People all over internet use that, or use drawable resource with app icon centered and background set to certain color, as described in this article: https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565
So my question is - Is it possible to achieve centerCrop behaviour when using windowBackground, so it works as below:
(Original provided fullscreen image on the left. Black border indicates device resolution)
Note I can't use activity layout for splash screen.

Related

Android GIF transparent background disappears

I'm new to Android Java programming. For a project I need transparent images, which change dynamically. I have created a layout with an ImageView. And in it a small GIF USA flag GIF with a transparent background.
In code I connect the variable to the imageview and assign the same image to the variable from the ImageResources
ImageView image = (ImageView)convertView.findViewById(R.id.listview_image);
image.setImageResource(R.drawable.vlag);
This goes pretty well however the image is displayed with a white background. The transparency is lost. This is shown in the image below by the white background.
GIF over ImageView are always an issue. Use GIFImageView
And you must use it this way:
gifImageView = (GifImageView) findViewById(R.id.gifImageView);
gifImageView.setBytes(bytes);
gifImageView.startAnimation();
Even it has an option to download the gif from the web.

Animating Crossfading between two images - Splash Screen

I am creating a splash screen for my app using multiple images. I have one main image that will be displayed as a Logo; behind the logo I intend to have two images - a green cloud, and a blue cloud, fading in and out a few times so it will create a kind of pulsing glow effect behind the logo. What is the best way to implement this type of effect? Basically the main image will stay static while the other two images switch back and forth from one to the other until the end of the splash intro. Thanks in advance for the help! BTW I am using Eclipse.
Have two images stacked - one way is in ht linear layout keep blue cloud as background and in the frame layout keep an ImageView. In the ImageView hold the green cloud. Now make the transparency of the image in the frame layout ("green cloud") fade in and fade out with its transparency. Call setAlpha in a loop -cycle the the argument to set Alpha - 0 is fully transparent wherein "blue cloud" is visible and 255 is fully opaque - "green cloud" is visible.

Splash screen which fills the whole samrtphone screen, but not crop

I want to have a splash screen, something like a full picture, which doesn't crop in heigth or width on different smartphone screens.
Now I achieved a splash screen with android:scaleType="fitXY", but now the image is cropped on top or bottom or if the devices screen size changes to another aspect ratio it is cropped on the left and right.
What do I have to do? I've already read the android developer article Supporting Multiple Screens, but I don't get it how to achieve this.
A simple picture in the middle of the screen is just simple to get, but a picture which fills the screen is hard to get. Can you help me pls?
you should use center_crop per this purpose. From the doc
Scale the image uniformly (maintain the image's aspect ratio) so that
both dimensions (width and height) of the image will be equal to or
larger than the corresponding dimension of the view (minus padding).
There is no way to create one single asset and expect it to do not be cropper and to do not create black areas when the application is deployed in different screen sizes.
The android platform is designed to work dynamically with multiple screen sizes that any manufacture can change at any time, including new resolutions that you haven't thought about it yet.
Android can specify minimums for screen hight/width categories in which your resources will fall, but those are generics.
In order to use them, you will have to specify qualifiers in your drawables and create a different splash screen for every qualifier, as for example if you use drawable-w420dp, all the resources there will be used when the screen has a minimum width of 420dp (notice that are not pixels)
So you have two options:
You can use one single splash image and design margins of that image flexible enough in order to cope with the image being cropped in certain cases. You can play with different scaleTypes in your ImageView and take as a reference this website http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html even though as commented before, "center-crop" will be your best shot.
You can programatically use a specific image for a specific resolution.
2.1 Put in the assets directory, all the splash images that you want for all the specific resolutions or aspect ratios that you want to use
2.1 Get the screen size of the device with Get screen dimensions in pixels
2.2 Now you can load from the assets the image that you want dynamically
Use the below code
android:layout_width="match_parent"
android:layout_height="match_parent"
which will fill the entire screen.
Try Using Width and Height of image to "match_parent"

Fullscreen Rotating Background Image

Developing an app for Android and I'm required to have a fullscreen image rotate (spin around infinitely, pivoted at the centre of the screen) in the background.
I have tried rotating the ImageView using RotateAnimation which works well, except the image is cropped to the size of the parent view.
I have also tried expanding the parent view to a set size (750dp) but it doesn't work well across all the different screen sizes.
Does anyone know of an easy way to implement this, which would involve scaling to uniformly fit the screen size?
Cheers,
Dylan
Screenshot of the image:

Android background image

I have a background image of size 720x1280 for larger screen phones like the LG Nitro P930. However, when I have an application that displays this image, it doesn't cover about half an inch at the bottom of the screen. The image looks fine on normal and small screen sizes, and I have included all of the support screens in my manifest file.
Is there something that I can do that will allow me to stretch the image to fit the screen, or am I doing something wrong?
add android:scaleType="fitXY" and fill_parent for height and width both in you layout xml
You don't have to use image view background should work fine, are you using a scroll view per chance somewhere?
I figured it out. It was actually a setting on the phone that optimizes the application.

Categories

Resources