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.
Related
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.
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.
Is it possible to turn rtl support on without reload activity. I am using detach and attach fragments and properties are translated, but rtl direction of elements works only if I reload or recreate() my activity. Is that possible somehow?
You can try using View.setLayoutDirection() to manually set a layout direction. Be aware the layout direction is considered a configuration change and there may be resources qualified based on layout direction, and it's better to let the system go through its normal process in order to pick up these resources.
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
Is this done by creating identically named xml files and placing each in drawable-ldpi drawable-hdpi folders? At the moment I am doing this but only different images are being used. No matter how I change the ldpi folders xml the hdpi's is used.
Am i doing something wrong? Or can I force the emulator to update (I am pushing the current apk to it) ?
The folder modifiers -ldpi, -hdpi, etc., can be used for other resource folders besides drawable. You can also have layout-ldpi, layout-hdpi, etc. Each would contain an identically named layout xml file, each with different xml (or not).
Be aware that the logic used in the emulator to decide what folder to use is rather complicated and depends on both the emulated dpi of the device and the scaling factor used for rendering the emulator screen. You may think you are emulating an ldpi device, but the emulator may still be deciding to bind the hdpi resources.