Android: different components for different screens - android

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.

Related

Is creating Android layout files for different DPIs necessary?

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 .

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).

What kind of layout is Android Home? Trying to Design my own Android Launcher

I am trying to create my own Android Launcher so I have been reading through Google's own Launcher2 code, Cyanogen's Trebuchet code and the Home Example provided with the ADK but keep coming across the same question: What kind of layout is the home screen (the one with shortcuts and widgets on it and with user-selectable wallpaper)?
From what I can tell, Trebuchet is based largely on the Launcher2 code but sifting through it is proving really hard.
Looking quickly at the Trebuchet sources on github at
https://github.com/CyanogenMod/android_packages_apps_Trebuchet
They seem to make heavy use of custom layouts.
While purely one example, some of the layout xml's make use of PagedViewGridLayout which is defined over in the src folder in a file called PagedViewGridLayout.java
public class PagedViewGridLayout extends GridLayout implements Page
GridLayout is in turn a standard Android component - and just by its name seems to be the type of thing you would want for a launcher. Obviously something as complex as current launchers is going to use many varieties and tricks for it's various configurable, interactive panes.
Your basic keys to understanding the sources will be figuring out the hierarchy of the layout xml files (and anything created from code rather than inflated from xml). Then looking through the inheritance hierarchy and mechanisms of the various custom layouts used.

How to create multi-pane layout in android

I want to make screen in which I have used multi pane layout.In screen ,left side show custom list view and right hand side show detail about click item.When I have run app in protrait from that show only single screen for example list.But on lanscape mode that is show list and detail page on screen.Please suggest me what can i do or example.
This is fairly easy with Fragments
And I think this is exactly what you want.
Android introduced fragments in Android 3.0 (API level 11), primarily to support more dynamic and flexible UI designs on large screens, such as tablets.
TIP:
If you update your SDK, and ADT plugin for Eclipse (If you are using it). You can even create a new project based on a fragment example! Which is very informative and easy to adjust.
You project has to have a minimum SDK version of 11.
Normally it would check with a configuration qualifier if you have a small handset screen or a big tablet screen, this check is fairly easy to find in your example project (Sorry I don't have much time to find a good example for you). Now you can change this configuration qualifier from large to large-landscape, or whatever you want.

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!

Categories

Resources