How to create a responsive app screen with transparent background in android? - android

I need to create a app screen that have a transparent background.
Like this,
Here is the result i need
I tried to create one using a 9 patch image but it's lost padding and margin, when changing the device size. Then i create images for mdpi, hdpi, xhdpi, xxdpi and xxxhdpi screens, but still same issue. It lost padding and margins and not align correctly. So how to create a app screen like this in android without using images. Sometimes this is a stupid question, but i spent two weeks and i cannot find a better way. I hope you can help me. Thank you,

Related

Supporting multiple screen sizes and rotations in android

Firstly I wanna say that I red probably all there is on internet on this topic.
I kinda get the picture about it but still I am not sure, and my brain is boiling trying to think about how it should go properly so I need somebody to clarify me these things maybe better than I found at other tutorials and topics.
Also a lot of questions and answers are kinda old and I know that these qualifiers for layouts like small, large and xlarge are kinda deprecated so refreshing would be nice.
So the thing that bothers me is how to support multiple screen sizes and orientations in android?
I understand that I need to support different drawable resources for different screen density's and that I need to use smallest width available qualifier for different screen sizes.
The thing that is the problem and I don't understand is how to accompany both of that together.
For instance for first example I have like logo sign which should draw over the whole screen of the mobile.
Can I actually provide all possible solutions and all possible sizes of that logo in all orientations or the android will size them as needed from the closest ones I give him?
How does the smallest width qualifier go in hand with different density drawable resources?
They just change the size of the picture depending on the screen dpi but they don't change the layout appearance.
Should I change layouts depending on screen sizes, and the pictures will change according to the density by itself what is actually a second example, because like buttons are different story, if they are 50 x 50 px in mdpi they will be 100 x 100 px in xhdpi.
And that's what I kinda get.
The bigger problem is how to put in the picture all alone that is filling the screen by itself and also to take screen rotations and changing of width and height with it in account.
So it was a long question, hope I told you what you need to know, the similar questions have already been asked but they are kinda old and outdated in some parts, and even there I still didn't find all the answers I was looking for so I hope I will find them here.
Looking forward for your help and thank you in advance !
I would say you're over complicating the topic, to support all sizes/layouts, you just have to keep them in mind while designing your layout. A vast majority of your layouts should only need to be built once and if they're built in a way that scales well it'll work out.
For example, if you're trying to draw a splash screen with a logo in the center, you can do something like this.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/my_logo" />
</FrameLayout>
This would work on all devices/sizes/orientations as it is just putting the logo in the center.
When building a layout, just focus on an average size of a current modern phone but keep in mind people have smaller devices. Use that as your base for assets, and try to include smaller ones, or use vector images.
And if you're building a View that is long, wrap it in a ScrollView so it can scroll on smaller devices.
I would only ever use the other layout directories ( for sizing or orientation ) for very specific cases, like when you want to completely change how your layout looks.
Hopefully that helps.

The proper way of sorting layout and drawable for different sizes and screens

I have scrolled through loads of documents and questions trying to figure out the right way of giving proper UI experience. I have a app with complex designs . I need to know how to scale my design to look fine in all devices. I got solutions mentioning that a normal layout folder with all layout , and i have traced all textview sizes and image view sizes to values, values-sw 480dp, values-sw 720 dp . Is this the proper dimens? My problem is that though the textsizes and image sizes scale up , still UI doesnt seem right. I mean the margin and all. What is the right solution out? any help?
#D try out to make different folder for different screen sizes like layout-hdpi
you can find the best practice for layout handling hear
and see the Google documentation hear
Good luck..
Its better to use Drawable qualifiers also
drawable
drawable-sw320dp
drawable-sw480dp
drawable-sw600dp
drawable-sw720dp

Xamarin different splashscreen tablet and phone

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)

Size images properly for mobile devices

Currently i'm trying to develop a mobile app for the Android devices (using Appcelerator).
There are alot of Android devices out there with different screen resolutions. So i basically want the app to look the same on every Android device.
So suppose i have a background image in the center of the screen. Which is (in pixels) 550x300.
I just tried to set the width and height of the imageviews to dips (density independent pixels). So in my case to: 332dp x 226dp.
I tested this first on an HTC One X. In there the image in nicely centered and i have a small space left on the left and right side to the edge of the screen.
Then i tested it on a slightly older device, the HTC Desire Z. In there the image width is a little bit more than the actual width of the screen. (example screen. The blue square represents the image)
So that means setting the width and height as dp isn't a good choice either for images.
What would be a good way to set the image width and height so that it looks the same on both phones. i.e., so that they both have a small white spaces on the other edges of the image left (like i have now in the HTC One X)??
Any advice on this matter?
edit
Thanks for the info so far. Some of you posted links to resources etc and made some suggestions. I'll try to work them out in the next few days, so i might take a couple of days before i accept an answer. In the mean time, any ideas suggestions are welcome.
Use the various drawable folders, i.e. drawable, drawable-large, drawable-xlarge to store your image assets for your background in various sizes. Review http://developer.android.com/guide/topics/resources/providing-resources.html for more information.
Also refer to Android: Scale a Drawable or background image? for helpful information.
I would recommend using a size to fit.
in objective c it looks kinda like this... not much of a android programmer but this may help.
CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;
_textView.frame = frame;
so if you could figure a way to get the frame size then you could set your image to that size any way the view is positioned.
and if you dont want it to take up the whole screen and just the sides then there might be a autoresizing function for android this way your image will be flexible with your frame which will vary based on the phone size.
I think the is problem is not that the image is wider, but the screen width of the phone is smaller on the HTC Desire Z.
I think the best way fot the image to look the same on all devices would be to set width/height programmatically.
But I think this doesn't really matter, as you will encounter much more complicated problems further wil developing for multiple devices. Both look good IMO.
What I would is set your android:layout_width to fill_parent and then add a android:layout_marginLeft and android:layout_marginRight in dip. You can also set a margin for the top and bottom, but based on your screenshots that doesn't seem to be an issue.
As a general rule, try to avoid setting fixed heights and widths for your widgets. Here is a great reference for dealing with different screen sizes:
http://developer.android.com/guide/practices/screens_support.html
So i basically want the app to look the same on every Android device.
No you don't. You think you do, but you really don't. That's like trying to fit a photograph in a 4x6, 5x7, and 8x10 frame -- something's gotta give. You have small phones, medium phones, large phones, 7" tablets, 10" tablets -- these are not the same experience and you simply have to allow some leniency to the design to make it work. If you just want a specific amount of space outside of the image, just give your ImageView a specific margin in DP units, e.g.:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
//...
/>
You should be striving to make the experience the same (although different layouts for tablets are highly recommended) but you can't expect it to look identical across all screen sizes and densities.

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.

Categories

Resources