Another topic about background image sizes - android

Let's imagine I want a picture of my dog as a background picture of a layout, and I want my application to be running on every smartphones.
I've read a lot of articles about this, and I just want to be certain that my dog will still look like a normal dog even if I use a tablet, a Nexus 5, or a moto G.
This subject is really similar to my problem:
Android: Background Image Size (in Pixel) which Support All Devices
According to the comments, it's not possible to have one image per resolution, because we have too many resolutions for android.
I just want an image of my dog as a portrait background.
Is it possible to do it? What is the easiest way to do it? What if my layout height is not exactly equal to the device screen height, but the device height minus another layout (fixed size) ?

Related

What picture size to use in Android layouts

I have an ImageView in Android with a foto in it. That view should always have the same proportions no matter which device it is displayed on. In my example the width of the ImageView is 427 dp and the height is 250 dp. I choose this special width to make the picture cover the whole width of the layout in Android studio. Now my question is, how should I modify the raw pictures taken from my camera (or whatever device/tool) such that it fits to the desired proportions? I mean, the raw picture does not have the desired proportions. This is why I extracted an ereas out of the picture with the desired proportions. I could specify the pixels for that in the tool I use (IrfanView). The proportions shoudld be multiples of 427 and 250, meaning that the following options are possible (427, 250) (2 * 427,2 * 250) (3 * 427, 3 * 250) etc. Now I do not know what size to choose. The ImageView might need different proportions depending on the device it is displayed on. Does someone have a good advice how to do that. Here you see a screenshot of the ImageView
Update: As nobody has answered so far, I would like to ask you again, how I should decide about the size of pictures in Android given that the app would run on different devices with different screen sizes. What is your way of deciding about that?
I'd be happy for every comment
Update 2: Can nobody help me with that? This should be a common problem. I mean you create an app for different devices and you need a picture for that app. What size should the picture have.
Why does nobody answer? Is the question itself unclear? If so please tell me.
try this i think you need two define two dimen files. one for normal phone and one for tablet. One size define in all dimen files. if you load in mobile normal fonts which you define for mobile will be load, if tab then tab font size.
How to define dimens.xml for every different screen size in android?

How big of an image do I need if it will be used as an iPhone app's background cover?

Suppose I want to make something where an image covers up most or all of the app's background, like this:
http://www.useronboard.com/how-slingshot-onboards-new-users/?slide=12
What is the minimum dimensions I would need? I know you need to get a higher resolution with iPhone apps.
It totally depends upon device/orientation for which you want to do so ideally it should not be less than screen resolution of that device.
For example: iPhone 6 display resolution is 1334x750 so you need image of that size to avoid any pixlation or disturbed aspect ratio issue.

How to can I create an image that can be used for different android screen sizes?

I created an image to use for an android splash screen and it displays properly on my phone however when I open the app on a phone with a larger screen it pixelates. So I was wonder if I should create more than one image and if so what sizes should I set for other images because I know I can't use the same sizes as I used for the app icon?
If the images are pixelated
then you need to add larger images for each screen size under your
res folder. sizes depends on your target
or
scale the images. to be safe, make it bigger
it might help you: am I supposed to make images larger for tablets, or same size as handset?
you could probably use draw-9-patch to state which area of the picture can be extended.
Google draw-9-patch
I worked with two approaches so far:
Screen composition
One approach can be using a composition of brackground and a logo. You can have the logo as big as you need (for high resolution screens) and the background as a repeatable texture (it all depends on your design approach) or a gradient or other composition (less prone to pixelation errors).
As big as possible approach
If one image is your approach, you should do a research to know the currently most used and biggest android screen used (https://developer.android.com/about/dashboards/index.html). Knowing that one, you can design your image for that [high] resolution and set the scaleType as CENTER_CROP. With that, you will ensure that the image will be centered, inside the screen, keeping aspect ratio, and at its highest resolution [keep an eye about logos/graphics positions if you want to be sure that they remain visible even in thin screens).
For icons, the best way is Draw 9-patch
Otherwise, you need to scale the images into drawable-xx (res directory), here the explanation

How to make an Android UI with images from a designer delivered as layers

I hired a designer to help me redesign the UI for my Android app. For each Activity he gave me an image for the background, which includes any static content like fancy frames for text content; plus images for the buttons, which must fit in to the background image in exact places, to fit into the frames in the background image.
However, since Android devices have different screen sizes and aspect ratios, it's easy to fit the background image by itself with android:scaleType="centerInside", but how can I get all the other images to fit in with background exactly, to the pixel? If they didn't have to fit in with the background, I would just set the exact width and height for each ImageButton, but depending on how the background scales (based on the screen size and ratio) they might end up not aligned correctly.
Thank you very much in advance.
Update:
Is there some way I can have an entire view (e.g. a RelativeLayout) scale inside the screen, like the way the image scales inside the ImageView with scaleType="centerInside"? If so, I would be able to set the RelativeLayout's size to the same as the background image, and put all of the other buttons / images in their places relative to the background image, and then just have the whole thing (the RelativeLayout containing all the other views) center inside the phone's screen.
Your approach is wrong (or at least bad), because android devices offer screens not only with different sizes but also with different densities. What you shall read now is Designing for Multiple Screens first. Then understand that non scallable bitmaped UI will rather not work as you imagine. You need to support screen sizes which means your UI elements (like i.e. buttons, lists, headers etc) shall scale. There's lot of possibilities to deal with this, one is using 9-patch bitmaps (randomly chosen tutorial on the 9-patch).
Also, please read this article: Supporting Multiple Screens
When desining UI it suffices to assume you design for mdpi density. Once your layout is done you create drawables for i.e. mdpi and hdpi (and put under the same names into res/drawable-mdpi and res/drawable-hdpi respecitvely). Layout files remains unchaged but framework would automatically pick right asset so your UI will look sharp as long as you provided drawables for that density. Please see Providing Resources article as well.

Android Layout: Display as much ImageViews as possible without scrolling

I am working on an app which should display several same size images on the screen. But it should only display only so much images as possible without offering scrolling.
E.g. On a "big" tablet it could display 10x10 Imageviews (screen is large, so there is much space for pictures)
On a "big" phone there might be enough space to display 6x6 ImageViews, so it should only display a 6x6 array of images.
On a small phone there is propably only space for 4x4 ImageViews, so it should only display this.
How can I make this in Android? I know about "layout-large", ... but if i make a special fixed xml-layout for a "large" device, it would not fit all devices correct. E.g. a Galaxy Nexus is a "normal" device and so is a Nexus One, but there would be at least be space for one or two more imageview rows on a Galaxy Nexus than on a Nexus One. So do I have to measure in code somehow how big the resolution is and display some TableRows accordingly? Or is there a special way how I can manage this?
you can query the properties of the screen of the device such as size, density etc. Once you know the size you can choose the layout to use.
Take a look at this stackoverflow post. Android: how to get screen dimensions
You should use a GridView to manage this.
GridView Android Developers
Edit: And indeed as Tomasz Gawel said: notice the GridView's android:numColumns="auto_fit" xml attribute
Edit: since you don't want it to be scrollable, you can just get the screensize, divide it by the size of your items, and put in only as much items as you want to display in the gridview.
The gridview will only scroll when it has more items than it can display.
getResources().getDisplayMetrics().widthPixels and heightPixels

Categories

Resources