Is creating Android layout files for different DPIs necessary? - android

I recently downloaded some famous apks(like Instagram) and unzip them, I found out that they only contain single "layout" folder, however, Google advised using layout-hdpi,layout-xxhdpi to support different screens.
When I develop my own app I find if I use "xhpi ratio"(1dp = 3px), the app works fine for almost all devices(from 320*480 to 1080*1920).
And I'm using Android Studio under Windows now, the default structure only contains "layout" folder alone.
So, is it necessary to create different layout files to support different dpis? And what is right way to adapt the various android screens?

Google advised using layout-hdpi,layout-xxhdpi to support different
screens
Where is it written? Usually drawables are put into directories with different density, but not layouts. Sometimes different layouts are created for different screen sizes (not density) and orientation (portrait, landscape).

Changing several layouts when you are changing/updating your UI is a pain in the a.. Make your best to keep as min. number of layouts you need to maintain for your own good. Make one for phone, one for the tablet if you really must.

It depends. I had done some apps with only one layout folder and also some which has even 5 folders to perform well on different devices.
I have mindset that if i use Relativeayout, i won't have to use multiple screen. Its just according to me.
If you have observed instagram doesn't contain much complex design so may be they did not need to. as well as they only had to put things inside container(relative or linear) and the container are in order .

Related

Android studio responsive design when creating layout programatically?

I am creating a layout programatically because it is so dependent on data requests, but because of this I can't use the different layouts (small, xlarge etc) to make my design responsive for different device screens. I made a java extention file that has a function which gets the device's screen width and height so i can pass in a percent value and returns it in px. Is this viable or is there any good way to go about this?
You should go for ConstraintLayout. It has been designed for Responsive UI. It is more flexible and you can easily design using Android Studio's Layout Editor. Make sure you are using the latest version of Android Studio.
Learn more here: https://developer.android.com/training/constraint-layout/index.html

How to design a responsive android app?

I am developing an android app and I want it to look good on every device, The way I thauoght was to set margin and size of views dynamically in java code, It seems OK and my app looks good on different mobile size, But recently I've been wondering if this is a right way and how this can effect my app, what is the best way to write a responsive app?
you can create separate resource files for the separate screen sizes by adding dimension qualifier to your resource directory. This will make your resource directory screen-size-dependent. This will provide you separate files for separate screen sizes like values-ldpi, values-hdpi, dimens-mdpi.... etc.
You can have a brief idea by having a look on this,
https://developer.android.com/guide/practices/screens_support.html
You might have a try first... or you can try this . Hope this helps!
You can make a responsive app by using constrain layout, using guidelines, and can use qualifiers.
Using a qualifier developer can make a different screen for different qualifiers.
eg: For landscape, we can make different layout
For better understanding, you can refer: documentation for responsive screen

Android screen compatibility - is it crucial to provide different layouts for different screen sizes?

A friend of my and I are working on an android app and we have an argument regarding to the proper way for supporting different screen sizes.
according to the following link (http://developer.android.com/guide/practices/screens_support.html), one of google reccomendations is to create different xml layout files for each acttivity/fragment.
for one hand - we would like that our application will run smoothly on several types of devices. from the other hand - we would like to work smart and effective, and to save valuable time.
therefore my question is what is the proper why to work? should we generate several xml files for each activity? or maybe to the complicated ones only?
or maybe we can work out without creating multiple layout at all? it seems like too much effort..
Thanks
one of google reccomendations is to create different xml layout files for each acttivity/fragment
That is not their recommendation. Quoting the documentation that you linked to, with emphasis added:
By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes. For example, on a larger screen, you might want to adjust the position and size of some elements to take advantage of the additional screen space, or on a smaller screen, you might need to adjust sizes so that everything can fit on the screen.
Google's recommendation,l therefore, is to have different versions of a resource for different screen sizes only where this is needed, where you determine if it is needed by trying it, seeing what it looks like, and determining that you cannot readily address any problems you are seeing by modifying the existing resource.
should we generate several xml files for each activity? or maybe to the complicated ones only? or maybe we can work out without creating multiple layout at all?
That is impossible to answer in the abstract, just as it is impossible to say whether you need custom CSS rules for different screen sizes for every possible Web page.
just try to make a layout but add multiple images xml to drawable for different different screens. doing this you can run your app on any size of screen (Not in every cases but it will help you).

Android layout translations

are there design conventions for layouts on larger layouts? I feel like this is a question few have asked.
A lot of android layouts don't look good on larger screens, or the user experience doesn't translate so seamlessly.
A critique of android apps is that they just stretch on large screens, but don't have any design considerations for them.
Is there a resource that details how a user might want to make their layout-large xml file, if their default layout xml file includes a listview, for instance. On the mobile experience, a listview with just text will be fine, where on the larger screen experience, the listview by itself doesn't look too good.
I would like to add extra layout files, but I don't have any reference on what they should look like, or even in the planning design phases of an app, I don't have any reference on how it ought to be designed so that other screen sizes can be incorporated.
Mainly looking for a resource that addresses these issues. Like maybe a blog post that goes into detail about this. Google's tablet design guidelines were a helpful start too.
Insight appreciated
Perhaps these resources will help you out. I would make the general statement that probably the most common technique for adapting layouts from handset to tablet is making tablet layouts multi-pane. You mentioned that you already perused through the Google design guide, but I figured I'd highlight the one page that talks specifically about this:
Android Design: Multi-Pane Layouts
The general concept is that information you would have presented on multiple screens on the handset (e.g. the list of items, followed by the view to display the selection) can be brought together on the same screen on a tablet (so the list now sits side-by-side with the view of the current selection). You mentioned already how the resource framework assists in selecting the proper layout; on the code side Fragments are intended to assist with modularizing the code that goes along with the view as well.
Another resource that may be of use is from Googler Kirill Grouchnikov. He has a series of blog posts dealing with Google Play as a case study and how conceptually the UI was broken up to work between the handset and tablet:
Responsive Mobile Design
Hope that Helps!

Android: different components for different screens

I need to create an application similar to file browser - with opportunity to move through the files tree and looking into files.
What I want - is to make one app for both phone and tablet.
On tablet I want it to look like "Split View Based Application" on IPad
On phone I want to have something like a button which shows the activity with files tree (which will be on the left on tablet)
Is it possible? I need to have a tablet-only-oriented activity with two groups (left one - for files tree, right - for file preview)
I already read about "Supporting multiple screens" on android dev. But they speak about different layouts of same components on different types of screen - I want to add there few "tablet-only" and "phone-only" components...
Or it's a dead-end?
It is definitely possible. I recommend Fragments for this task. They were introduced with honeycomb and are exactly for this kind of reusable UI parts you have in mind. There is also a compatibility lib for lower android versions (I believe down to 1.6.) inside ANDROID-SDK/extras/android/compatibility.

Categories

Resources