Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to develop an application for Galaxy Tab and Android phones. The tab and phone UI are very different. Like in tab, we have used fragments, etc. and on the phone we want to use tabs.
I am aware that by using layout-small or layout-large I can show different UIs, but what about functionality?
How should I proceed? Is there a simple way to handle functionality also for different screens? Or is it better to create two applications finally?
First be sure to read this recent blog post that gives an overview of how applications see different screen sizes and can adjust to them:
http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html
This post has some examples of basic adjustments -- providing different layout files for different screen sizes.
This is also something that the fragment APIs are intended to help with. If you are already writing your UI with fragments, you are most of the way there -- showing these in tabs does not require a totally different implementation, just use the fragments to populate the different tabs.
If you are targeting Android 3.0 or later, this is easy because the action bar already has simple mechanisms to have its tabs allow switching between fragments. This API demo provides a very simple example of its use:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.html
If you want to run on older versions of the platform, that is what the fragment APIs in the v4 support library are for. These allow you to write your app using fragments and still be able to run all the way down to Android 1.6 (API 4) of the platform. In MR2 we also added some sample code showing how you can use the support lib fragments with the old tab API.
Sample code for this is included in the now deprecated TabActivity class:
http://developer.android.com/reference/android/app/TabActivity.html
There's no single answer to this - it's a broad topic.
One thing to keep in mind before you start, is that there's currently a lot of code floating around the web that assumes you can judge a screen size by the platform version: IE, everything up to Gingerbread is a phone, and Honeycomb (and up) is a tablet. This is a bad idea. Don't do this :) Also try to avoid a massive switch case that just executes different blocks of code based on width/height values you pull from the system. I'm not going to describe how to do that, others have already given that answer.
One thing to investigate is the Android Compatibility Package - It lets you use Fragments and Loaders (which were introduced in Honeycomb) in earlier versions of the Android platform. One common pattern this enables is to let you set up a nav fragment & content fragment which sit side-by-side on a Tablet (where there's room) but have the nav fragment switch over to the content fragment when an item is selected on a phone or smaller screen.
If you're just trying to have images that grow and shrink with screen size (that you're not drawing programmatically), the answer is 9-patches.
You also have the option, if it's appropriate for your application, of using Android Market's Multiple APK support. The linked page dives into how to set that up, and gives you a pretty solid description of when to use it and when you're better off with a single APK.
You can retrieve the screen size using:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
You will have to have decided which screen sizes are required for the different features, such as setting the minimum tablet height and width to min_tab_height and min_tab_width, accordingly. Then do a check for if this screen size qualifies:
boolean is_tablet = false;
if (width >= min_tab_width && height >= min_tab_height) {
is_tablet = true;
}
Now you can check if (is_tablet) before allowing tablet functionality to your app (or if (!is_tablet) for non-tablet functionality.
Try splitting your app in seperate parts, one trunk containing core features that you develop as a Library, then two separate apps using the same core functionality with specific UI design, one for Tablet version of Android (>3.0 HoneyComb) and one for "phone" versions (<3.0).
My experience with GalaxyTab-likes (basically a tablet with a 'phone' non-HoneyComb version of the OS) is that phone layouts do stretch nicely to fit the 7 inch screen. So it might be enough to add a specialized layout.xml specifically made for big screen. However I didn't even found it necessary on my own app...
EDIT:
also not that if a tablet is running a non-honeycomb OS, 2.2 or 2.3, like is the case with GalaxyTab and many 7 inch tablets, the functionality is exactly the same as on phones, so no specific redesign is needed if not for the layout of UI components.
EDIT:
read this page for specific and detailed information on how to support different screen size in your app. You can specify in your manifest the size of the supported screen for your app with
<manifest ... >
<supports-screens android:requiresSmallestWidthDp="600" />
...
</manifest>
So given the market now supports uploading several apk for the same app, you could compile different version of the app seperately for each screen size, and the market would filter them out according to the sizes in Manifest, so you should even never have to actually check for screen size in your code.
Related
The screens in my app needs to be displayed in the same way on both type of devices, phones and tablets. Currently my app works fine on phones, but they behave weird when run on tablets. The problem occurs with the positioning and size of components in the screen.I have 9 patch images generated for all the images being used but still for some components that I use absolute size/margin values such as 30dp,50dp etc do not seem to be good measures that work well on a tablet. Some of my thoughts/questions are:
PercentRelativeLayout - is it the best solution to overcome this
problem?
Is there a way that layouts can be defined so as to draw
differently on phones and tablets. Please note that that I do not
have any complex menus or behaviour that needs to work differently
on different devices, they are same.
Do I have to develop 2 different apps?
you have to make different layouts for both android phone and tablet.
Look at this link
Read more on the Android developer documentation after reading answers above. Found this resource to be more explicit for someone who is totally unaware of supporting multiple screens. http://www.survivingwithandroid.com/2012/07/how-to-support-multiple-screen-in.html
I've been using Xcode for a few months now to create basic iOS applications. Within the startup settings, it allows you to select 'iPhone', 'iPad' or 'Universal'.
I usually setup my applications so that they are locked portrait on iPhone and locked landscape on iPad.
Firstly, how can I setup my project so that it is available to both smartphones and tablets when pushed to the Google Play Store?
Secondly, is there a way to set the orientation to portrait for smartphones and landscape for tablets?
I think what you want is that the app should adopt its view according to whether the device is a phone or tablet. If so, Android provides a very good design called Master-Detail Flow. In a master/detail navigation flow, a master screen contains a list of items in a collection, and a detail screen shows detailed information about a specific item within that collection. And the beauty of it is that, in a phone it only shows the master view as a list and in a tablet it shows both master and detail in two panes.
Take a look at this and this
Also for other adaptive UI see this
The concept of Android O.S is entirely different from iOS. Primarily, think of all the Android devices that exists! Lot of manufacturers, in different screen sizes and with varied configurations. However, an Apple iPhone is designed and manufactured by Apple, and it comes like a brick in different sizes. So it offers more of a robustness to the developer.
But in Android, due to it's versatility, there comes a need to design apps that runs equally same in all devices even with different screen resolutions. As a result, Android uses a technique called DIP Display independent pixels to address while designing. [This] is the perfect place to get a structured knowledge on Android UI designing and scaling to different screen sizes.
Now coming to your second question, Android offers superior flexibility to the developers. And you can easily adjust the orientation programmatically:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //<-- Landscape mode
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //<-- Portrait mode
Hope this clearly answers your query!
Android Wear Watches are a lot smaller then Android phones, but when looking over the Android API pages and training guides, I didn't see any restrictions on layout elements. Some layouts, however, wouldn't make sense on some watches. For example, a large custom layout ListView wouldn't fit very well on round watches. Are all layout elements really available on Android Wear?
Not all layouts are available (WebView for example). You can see the unsupported libraries here.
And some layouts are meant to be used in Android Wear only.
There is no restriction as far as I know. There are some adjustments that one need to pay attention to in order to have a pleasant UI on both square and round displays, by adjusting the location of items and taking advantage of what the platform adds for handling round vs square, etc but outside of that, all the layouts are, as far as I know, available there too.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have a task to convert an iPad application into Android tablet.
I get into my concerns right away.
iPad screen resolution and size is only 2 different versions, so you design in the small resolution and add graphics for the bigger one too. That's fine in Android you have the drawable folders. But when you testing in emulator shouldn't I set the resolution iPad like? 1024x748 and test my app there? OK I will have my values with dp,sp, wrap content, fill parent, but my target devices are tablets. What would your opinion be in setting up the emulator for such kind of task?
Next is what about some things with architecture. In the iPad I have views and subviews, child controllers appearing "on top" of the other controller. This can happen with fragments I think so far but, can these fragment layouts have a dimension? or you are just hanging on wrap content etc? I mean you have a view 1024x748 and another view appearing top of it bottom right on the screen 300x300 for example. Different controllers, different views, exchanging data! Any example tutorials on such a design?
Can I just show a "popup" kind with various views inside in a specific position on screen? Like you push a button and a view rectangle with a pointing arrow appears next to it.
Thank you in advance and I hope you can understand what I'm asking. Comment for any inconsistency.
What's your question here? You have to create a similar App on Android as you have now on iOS. The two platforms are different, both in API and in UI terms. Thus, first of all, you/or a designer at your cmpny have to redesign the app, so it fits into the Android world... So in other words, what matters here is "WHAT YOU DO", not "HOW YOU DO"... You have to design the same experience for your Android users... And that does not start with simply porting your app, and coding.
You should NOT simply take features form the iPad app, and directly force them into the Android version, as the look&feel, the behavior of the two systems is different. You should dig deep into Android Design Guides before starting that... HERE and HERE
E.g.: In the iPhone world you can use absolute positioning, as you have only a few valid resolutions. In the case of Android, layout has to be dynamic, as you have tons of different resolutions. The recommended layout of programs, the number of hw buttons, these are different. The user expectations are different. An Android phone is operated differently from an iOS based device... Users are expecting functions to be accessible in different ways...
Another approach is to use a framework that enables designing apps for every different platform. Thus, they have an abstraction layer on top of which (with it constraints) you design your app, and than you are able to release it to all of the different platforms (iOS, Android, WP7, W8, Bada, etc, what the actual platform supports..). HERE is an article on such platforms.
I'll give it a try to make something meaningful out of this.
To the emulator screen size
Android come in any size and shape so you should develop for that. Sometimes it can be an advantage to actually set the dimensions in the emulator to something obscure just to see if it looks good. That said I'd test on the most popular tablet brands like:
Nexus 7, Asus transformer eee pad (1280×800)
Nexus 10 (2560×1600) (hard to test due to the large size)
Amazon Kindle Fire HD (1280 × 800) (same as nexus but some report indicate it is handled differently, so if you got a physical one test it)
In general you should always test on a multitude of screen sizes but also a multitude of devices as there always is some differences you don't think about (like with the amazon kindle fire HD), so get your hands on as many tablets as you can or use some kind of test service.
About architecture
Android has views and sub views as well. Fragments is a simple combination of code and view and like views have a size. Fragments can easily exchange data but it happens through its parent activity.
You don't EVER want to position different views at a specific position on the screen. Setting UI for android is more like setting UI for a webpage than for a newspaper. You don't have a specific size but a size that various for each device. So you should make a layout that can be stretched to the various sizes and still look good. This can be accomplished in numerous ways.
I have to program my Android app with the best compatibility to different screen sizes (tablets and smartphones) and to the versions 2.3, 3.2 and 4.0.
I know about the possibliy to name the folders of the layout like res/layout-sw600dp/. to match the layout exactly to different screen sizes.
So, cause I will use completely different layouts for Tablets / Smartphones, I would start with a "Load Screen", which tests which Android-version is used and if there is used a tablet-or smartphone-device, cause for example in the layout for the Tablet, there will be Buttons on some screens that won't be there on the smartphone.
So I will have to separate all this in packages, like this:
Common
2.3
Tablet
Smartphone
3.2
Tablet
Smartphone
4.0
Tablet
Smartphone
I would choose this separation, cause it's the best way, in my opinion, to be prepared for upcoming *updates*, if, let's say there should be added a Button in the ToolBar in Android 4.0.
Is this separation a good thing in your opinion or is this a complete overload?
Are there any other new features in 4.0 that I should be aware of?
You can also name your resource folders to indicate version number (like /res/layout-v11) or (/res/values-v13)
Regarding your question about separation - it really depends on your particular requirement. A common approach to this problem is a fall-back mechanism: You provide a few specific layouts (for example, an xlarge landscape v11 layout), and a few generic ones to fall back to.
Of course, this is an "idealistic" solution; and it doesn't always work that way. In other words, it is mighty difficult to practically implement an app that is compatible with so many versions of Android solely by providing alternative resources. Even if you use the compatibility libraries (which helps a bit in reducing version-specific code); you will still have to adapt your code based on the version at run-time.
You can find out the Android version looking at Build.VERSION.
The documentation recommends you check Build.VERSION.SDK_INT against the values in Build.VERSION_CODES.
And based on that version you can set your layouts in if else conditions