Xamarin different splashscreen tablet and phone - android

We have a big xamarin project. We have multiple splashscreens, for phone and for tablet. The splashscreens have a logo on them, which can't be stretched. You can put a splashscreen in the drawable folders, but then you can't detect if its a tablet or phone.
How is it possible to configure multiple splashscreens, not only based on the drawable folders? Thanks in advance.

Although this may not be the fix you are looking for, I can suggest looking at the Xamarin guide for detecting screen density . Here you can set a certain threshold (certain number of pixels in height and width means it is a tablet) and set one of two drawables you have. One splash screen for tablets and the other for phones.
I don't know what the splash screen looks like, but if it is simply the logo that is important (say if you have a solid color background) possibly make a layout that fills the screen with a background color and center_horizontal + center_vertical your logo drawable (that way you only need one drawable for all splash screens)

Related

Use non-fullscreen image for splash screen

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!!

How to make our app run in all the screen sizes without getting our components collapsed and mergen into each other?

I made a single activity app with a picture and a text box and a get started button.Picture isl located at the center,text box just beneath it and button at bottom right corner..but when I run the app the picture and the text box are overlapping each other...and the button is located at the bottom center ......so how to make sure that this doesn't happen.
create dimens in dimens.xml folder for different screen size .
like dimen.xml(sw560dp). and define size for different widgets in different dimens.
Few things you must keep in mind while making screens compatible to multiple screen sizes.
Use dp instead of px in your dimensions.
Use proper layout management. That is use linear layout wherever possible.
Images should have 5 copies for mpdi, hdpi, xhdpi, xxhdpi, and xxxhdpi.
For further details visit this link

Android mdpi drawables for use on both Droid phone and Xoom?

I have an app developed for a Droid (phone). In the app, I use:
Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
To set the background bitmap in the application. The bitmap is sized 480x800
which is the WVGA screen size of the Droid (without status or title bar).
Two questions:
When I rotate the phone, the Droid goes into landscape mode and the background no longer fits correctly. How do I tell the App it needs to use landscape mode when I'm not using a layout?
Second, when I run this app on the Xoom, it picks the mdpi drawable which is nowhere near the size of the Xoom screen. How do I define a second mdpi drawable that has a 1280x800 size? I think if I were using layouts, I would create a layout-xlarge directory and place a 1280x800 background in the imageview of that layout, correct?
Thanks!
Update *:
Thanks for the great answers! I upvoted everyone.
I updated the code to use drawable-xlarge-port/drawable-xlarge-land for the Xoom and drawable-port-mdpi/drawable-land-mdpi for the Droid.
I'm not using layouts as I needed to draw directly onto the activity canvas and not sure how to use setContentView() from within the class where I extend View and hook into onDraw() in order to do the animation (would need to be a separate posting).
If I can figure out how to rotate the image myself I could indeed do away with the drawable-*-land and *-port directories.
You can target drawables, not just layouts. You want drawable-hdpi-large-long-land for the first situation (assuming you're letting the system handle rotation events and recreate your activity), and drawable-mdpi-xlarge for the second.
Of course it's futile to try to ship with a separate image for every conceivable phone resolution; partially because there's a lot you'd need, and partially because some targets aren't differentiable (the 854x480 and 800x480 phones out there are all hdpi-large-long, for example, despite the 54px difference). Try to use a scaleable image, a stretchable 9patch, or an image you can just fix at the top-right corner (you can define stretch behaviors using an XML-defined bitmapdrawable).
When I rotate the phone, the Droid
goes into landscape mode and the
background no longer fits correctly.
How do I tell the App it needs to use
landscape mode when I'm not using a
layout?
If you alreay detect the rotation, then the Device class is the way to go.
Second, when I run this app on the
Xoom, it picks the mdpi drawable which
is nowhere near the size of the Xoom
screen. How do I define a second mdpi
drawable that has a 1200x800 size?
You can use various image folders dependending on the resolution of the device: ldpi, mdpi, hdpi or xhdpi. You should take a look at the following page for proper support of various resolutions and screen sizes.
That's just about right. You can mix in portrait, landscape, and other modifiers, too. Don't forget to use them with your drawables as well as your layouts (and any other resource directory, for that matter). If it's the same layout and different drawables, then you only need to apply it to the drawable, for instance.
You'll want to look at the documentation for resource directories and make use of the size and orientation directory modifiers.
For example:
drawable-land-mdpi
drawable-xlarge-land
layout-port-mdpi
and such
For more information, see:
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
http://developer.android.com/guide/practices/screens_support.html#qualifiers

How to design image for splash screen?

I would like to show a splash screen image. I've read Screen compatibility overview about the different directories (ldpi, mdpi, ...) to create under res/ but I've not understood if, other than creating the same image of 240x320, 320x480 and 480x800 I need to do other things to achieve a good result.
Can anyone suggest me which is the best thing to do?
What you describe is what you need to do. You need an image for each screen pixel density group (ldpi, mdpi, hpdi and poss xhdpi)
Other things you can do?
Use a background around the image so the image appears to stretch (e.g. if image is white near the edges, use a white background). It'll look better if there isn't an obvious border around the image and it fades into a background.
The background/borders could be a 9-patch, stretchable image
In theory you could provide a lot more images and select them at runtime based on actual screen size, but it's a very bad idea (you never know what new sizes are coming)
Remember to include portrait and landscape versions - never a good idea to assume one orientation if you can possibly avoid it
Think of an Android screen like a resizable web page - they come in various different sizes and shapes, and your layout needs to stretch and adapt for all.
Like Ollie C said, I also make a 9-patch that I set in background, the only probleme with this methos is that your Splashscreen must have uniform stretchable areas.

What resolution should my Android splash screens be?

I'm creating a splash screen that will display while my Android application loads. I'd like to create it at the correct size so Android won't auto-scale it up or down to fit the screen. (It's a bitmap image, a photograph of an oil painting, so I can't just turn it into a nine-patch.)
But there are at least three important screen sizes I care about: 320x480, 480x854 (Droid), and 480x800 (Nexus One).
I've read the documentation on supporting multiple screen sizes, but I still don't see how I'm supposed to configure different splash screens for Droid/Nexus one (they're both "hdpi" resources as far as Android is concerned), and I don't know exactly how large my splash screen should be in any case. (How tall is the OS title bar/menu in Droid? N1?)
What size should I make these images, and how do I tell Android to use the correct size on a given screen?
You don't need to worry about the absolute screen size or status bars or anything — that's why we have nine-patch images.
What I did was have an image that looked good for each resolution — essentially a logo on a transparent background, with some text at the bottom.
Then I chopped off quite a lot of space at the top and side edges, made a nine-patch border round the image, with a single pixel near the left, right and top edges. This allows the image to expand evenly at the sides and top to fill the screen.
Edit, in response to Dan's comment below:
Yes, there is a way to determine which graphics should be used for which explicit screen sizes, but it's deprecated.
Just as there are drawable-hdpi and -ldpi resource qualifiers, it's also possible to use drawable-HHHxWWW — the larger pixel dimension coming first.
e.g. drawable-800x480 and drawable-854x480
Okay, firstly: you can find the device model via android.os.Build and use that to determine which image to show.
Secondly, I personally wouldn't bother. Layouts should be done in dip since every android screen is 320x480 dip I believe, and android maintains aspect ratio among devices very well through this in my experience. A 480x800 splash set to fill parent has been pretty reliable on both N1 and the droid as far as I have encountered.
Another solution that I implemented is to put an ImageView that fills the screen (width and height both "MATCH_PARENT") with scale type "centerCrop". This way, the image is not stretched but cropped along the edges. Try not to put important content (logos and stuff like that) close to the edges. If it is a photograph, I hope that the edges are "expendable" and can be cropped out.

Categories

Resources