I am making an Android App and have created the basic layout for devices.
But I also want to make the layout for Tablets. I know I can use the different size layouts.
But what should be the ratio of normal layout sizes to the tablet layout size. Any help will be appreciated.
The documentation you are looking for is here . The value you should be using is 600dp as described in the docs
res/layout-w600dp/main_activity.xml # For 7” tablets or any screen with 600dp
# available width (possibly landscape handsets)
So basically you can create a layout-w600dp folder inside of the res directory to be used as the layout for tablets.
Related
Currently I am developing a android mobile app using android studio (java). Since it should multiple screen size I make another layout file with respect to the screen size which i need(xxx-high density). But still it is not supporting. The buttons are moving out of the screen.
I have used Relative Layout as a parent layout for all of my activity.
please somebody help me to get out of this trouble.enter image description here
Just do as the folowing,
res -> layout -> New -> Layout Resource File
Dont forget to give the same file name, just specify the size.
When I run the app on a real device and I rotate the app to landscape mode most of the content is been cut off and I can't even scroll on the landscape mode. What XML or java code can I use to make the app rotate without loosing it content?
Please check the attached image to understand what I mean
In the folder "res":
create a new folder named "layout-land" where you copy the layout (the layout need to have the same name).
Modify the content of the layout as you desire to fit the landscape.
When you rotate your phone, the system will detect that it exist a layout land folder and a layout adapted for landscape.
Can you post your layout code? I will help you to organize the views.
Earlier, I asked this question:
Landscape mode for app?
Where I had a directory for each and every layout, but the layout in the layout-land directory wasn't showing up when positioning my layout in landscape orientation.
So, someone suggested to me that it maybe that the
Layout-normal directories are overriding my regular layout-land directories. Is this true?
If so, will any other of my layout folders get overriding? What is the purpose of layout-normal in the first place then anyway?
Thanks,
Ruchir
First understand, how resources are pulled out in android. If your device is large, then the layout from layout-large gets loaded. If you device is normal then the layout from layout-normal gets loaded. But if the android system is unable to determine whether the device is large or normal or anything else. Then layouts from the layout get loaded.
i want to clear my all doubts about android multiple screen support.
i have searched a lot but not found any solution for it.
i can clear my question by giving an example.
first i have a screen 480*800 and i have all image resources used in this screen with relative to this size(480*800). and i have created my layout using wrap_content attribute.
so i want to ask where i put these image resources in drawable hdpi or mdpi or ldpi or x-hdpi.
for example if i put these in drawable hdpi then what about other folders and other screen sizes.
i have read all Article on developer's website but i didn't found any solution.
or where could i found a complete tutorial whit handling this issue.
Thanks in advance.
PUT THOSE FILES WHICH YOU WANT TO USE FOR ALL TYPE OF SCREEN RESOLUTIONS IN drawable FOLDER , IF YOU WANT TO USE PARTICULAR SCREEN SIZES THE PUT IN hdpi or mdpi or ldpi or x-hdpi , u have to create a folder "drawable" for all common sizes .
480 * 800 is a mdpi device. You can can put these image resources in drawable-mdpi if you want the device to auto adjust for smaller and larger screen sizes. If you want these images to be of maximum size you can put it in drawable-xhdpi.
If not i.e. if you want same image to be used in all the screen sizes then you can simply put in drawable folder in resource.
For more information you can check this :developer link
I am working on a small app, with 3 buttons on left corner(Vertically) and a edit box which covers rest of the screen.
I want to run this app to be able to work on all screen resolutions.
So I have used Relative layout, linear layout and Android:weight for buttons, which equally share the size of the buttons and works fine.
My Question is am I doing it wrong?
Should we design different layouts for different screens or using same layout out but adding properties like weight and padding is fine??
So, you want a responsive layout for your android app.
Pointing to your question :
[+1] layout -> Relative / Linear (in addition to the relative layout)
property (Buttons) -> Android:weight
is the right thing you are doing for your app.
Alternative:
But if you want a more responsive design then you could follow responsive design techniques by using html5 & css3 media queries etc. . And, could opt for a fluid layout also. By doing this the advantages you will have are:
Won't have a native UI only for android but the same could be used for other platforms (iOS,blackberry etc.) if you require.
The design would be more seamless with the native browser and the widgets won't get obsolete ever in the newer versions of your android
platform also and changes once done would be reflected over the other
platforms too.
More info: MUST READ IF YOU WANT CLEAR UNDERSTANDING OF HOW TO DESIGN FOR ANDROID
http://developer.android.com/design/style/devices-displays.html
http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm
you can see this Supporting Multiple Screens and also Designing for Multiple Screens
To support different screen size you have to implement different layout.
Under res directory you should create these directory:
layout
layout-small
layout-large
layout-xlarge
In each directory you implement your layout. be aware to call all the layouts with the same name.
If you want to support the landscape mode too you have to add:
layout-small-land
layout-large-land
layout-land
When, in Eclipse, you open the layout select the tab called 'Graphical Layout' , you will see how your layout will be displayed. Change the screen size using the options in the upper left side and you can check how it will be displayed in different screen size.
If something is wrong you can open the xml using and correct it.
I've created a small tutorial here Multiple screen support
Hope this help you