There is a solution to resize automatically the views of my android app?
I've optimized it for 7" screen.
But now I want to use it on 3.2" screen and it's looking horrible!
I've you got some ideas or I have to do it manually?
This would be the first stop I would recommend:
http://developer.android.com/guide/practices/screens_support.html
This document explains the screens-support features provided by the platform and how you use them in your application. By following the practices described here, you can easily create an application that displays properly on all supported device screens and that you can deploy to any device as a single .apk."to any device as a single .apk.
and check this pdf: http://www.vanteon.com/downloads/Scaling_Android_Apps_White_Paper.pdf
Define sizes/dimensions in the dimens folder, and set sizes to your Views programatically through Java.
Or, you could set the size based on some ratio, according to the screen size. I mean, you can calculate the width/height of the screen during runtime and make the dimensions of your view screenwidth/x.
Please read this tutorials from Android developers:
Supporting Multiple Screens
Designing for Multiple Screens
Related
I designed an app with dp unit. I also used RelativeLayout. I designed app while Pixel 3XL screen selected like this. After i finished the design i changed the screen to the Pixel like this. Now my design looks bigger.Look the red line. Not equal to the Pixel 3XL. I want my app to look the same on every phone. Thank you.
From Document:
Android devices come in all shapes and sizes, so your app's layout
needs to be flexible. That is, instead of defining your layout with
rigid dimensions that assume a certain screen size and aspect ratio,
your layout should gracefully respond to different screen sizes and
orientations. By supporting as many screens as possible, your app can
be made available to the greatest number of users with different
devices, using a single APK. Additionally, making your app flexible
for different screen sizes ensures that your app can handle window
configuration changes on the device, such as when the user enables
multi-window mode.
This page shows you how to support different screen sizes with the
following techniques:
Use view dimensions that allow the layout to resize Create alternative
UI layouts according to the screen configuration Provide bitmaps that
can stretch with the views
https://developer.android.com/training/multiscreen/screensizes
https://material.io/design/layout/responsive-layout-grid.html
Try using constraintLayout if you want to build responsive designs.I have tested it on multiple devices and google also recommends it.Go through the link.
https://developer.android.com/training/constraint-layout
I want to make my view Responsive, look at following images.
1st Image is what it should ideally look.
But when I change the screen size, it changes the size and alignment. I want fixed size views over all screens.
You should follow Step by Step approach .
Android runs on a variety of devices that offer different screen sizes
and densities. For applications, the Android system provides a
consistent development environment across devices and handles most of
the work to adjust each application's user interface to the screen on
which it is displayed.
Read Supporting Multiple Screens .
To optimize your user experience on different screen sizes, you should
create a unique layout XML file for each screen size you want to
support.
Read official guideline about Supporting Different Screens .
Read Build a Responsive UI .
I'm developing an apps for both phone and tablet, but the problem is that when we run it on a tablet then the image that we have used in the app doesn't stretch and looks different. But we want to develop it like on the phone. Is it possible or not if yes then how? I have used image .jpg and .png.I think the problem is the image, the java code is perfect.
See Android Developers: Supporting Multiple Screens
In order to be independent of screen size, use dp (dip) instead of px when you design your xml-layouts. And use sp when you define text-size.
You should provide properly sized image resources for the different screen sizes. This can be accomplished in Android using the built in Resource system.
You can use the sdp sdk. It enables you to use the sdp size unit which fits to the screen size.
I have been learning android development and I am still new to this.
I have already designed many apps for iOS.
Is there a better way to have my layouts as easy as iOS?
because in iOS I only have to drag and move it wherever I want . Where in android I have to insert tables and edit XMLs, which I find very confusing and not flexible to deal with.
I have read and watched many tutorial and still find it a bit difficult to deal with
Thanks
There is a layout editor for Android that you can use in Eclipse. Is that what you're looking for?
http://developer.android.com/guide/developing/tools/adt.html#graphical-editor
The short answer is NO. The long answer is that this is how it's done on Android, and it's much more flexible than the iOS method. Just imagine making Android app the iOS way and support screen sizes such as 240x320, 320x480, 480x800, 480x854, 540x960, 600x1024, 720x1280...and so on, and it's easy to realize that it would be an impossible task. This is almost certainly why Apple went with "Retina Display" with exactly 2x the pixel density and exact same screen dimension (3.5") - because doing anything else would mean that all the apps would need to be designed specifically for the new screen instead of just providing images with a #2x postfix.
So, instead of absolute positioning and sizing like the iOS, XML is used in Android where designers are tasked to come up with one or more layouts that can support this diverse range of screen sizes.
You can use Eclipse Layout Editor for Drag and Drop with absolute layout. But using absolute layout is not a good practice because in iOS screen size is fixed for all device but in android there are different screen size device are available and if you design a layout considering a single screen size it will be messed on another screen size device. You must follow the norms to create a layout go through this link for more detail.
http://developer.android.com/guide/topics/ui/layout-objects.html
i want to develop an application that support resolution for both phones and tablet and for both layouts protrait and landscape .So can any one suggest me what i have to do for that ?
Thanks in advance .
These links should help:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/guide/practices/tablets-and-handsets.html
http://developer.android.com/training/multiscreen/index.html
I created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units for one size is not enough if you want your app to fit on all devices and tablets, since there's four different "density-buckets". This tool will allow your layouts to be converted into fitting these density buckets.
It really depends on the type of application. I've been doing raw drawing in OpenGL and with SurfaceViews, so I make sure I get viewport or canvas height and width and scale things accordingly.
If you have very specific UI elements, take into account DPI to ensure a button or widget is a minimum size.
See this link: http://developer.android.com/guide/practices/screens_support.html.
You can place your xml-Layouts for Tablet in 'layout-xlarge-land' and for phones in 'layout-large-land' or in the normal layout-land. For Portrait-Mode just place you xmls in 'layout-port'- Folders.