Sign in to follow this  

Developing different views for different android devices?

This topic is 2063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have my main.xml page designed for tablets becuase they have more screen space. I made a second xml file named phone.xml and i was wondering if anybody knows how to make the app check what device is using the app and automatically change depending on if it is a tablet or smartphone.

So if it's a tablet it will use main.xml and if its a smart phone it will use phone,xml for the menu.

Share this post


Link to post
Share on other sites
I think what you're looking for is a concept in the Android SDK known as Fragments.

You can find a full explanation of these here:

[url="http://developer.android.com/guide/topics/fundamentals/fragments.html"]http://developer.android.com/guide/topics/fundamentals/fragments.html[/url]

Share this post


Link to post
Share on other sites
You may want to look into providing alternative resources from the [url="http://developer.android.com/guide/topics/resources/providing-resources.html"]sdk documentation[/url]

Share this post


Link to post
Share on other sites
[quote name='Zael' timestamp='1334077508' post='4929936']
You may want to look into providing alternative resources from the [url="http://developer.android.com/guide/topics/resources/providing-resources.html"]sdk documentation[/url]
[/quote]

This is the easiest way to go for what you are looking to do. Its actually one of androids most powerful features.

Essentially you create two layout folders
layout
layout-xlarge

you place all your tablet specific layouts in the layout-xlarge and they will automatically be used on those devices. You don't need double up either so if you have the same layout on both the phone and tablet you just place it in the layout folder and it will be used everywhere.

You can do all sort of complicate layout changes using this method like:
layout-land and layout-xlarge-land if you want to use a different layout when the phone is in landscape mode.

Share this post


Link to post
Share on other sites

This topic is 2063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this