I am creating a layout programatically because it is so dependent on data requests, but because of this I can't use the different layouts (small, xlarge etc) to make my design responsive for different device screens. I made a java extention file that has a function which gets the device's screen width and height so i can pass in a percent value and returns it in px. Is this viable or is there any good way to go about this?
You should go for ConstraintLayout. It has been designed for Responsive UI. It is more flexible and you can easily design using Android Studio's Layout Editor. Make sure you are using the latest version of Android Studio.
Learn more here: https://developer.android.com/training/constraint-layout/index.html
Related
I am developing an android app and I want it to look good on every device, The way I thauoght was to set margin and size of views dynamically in java code, It seems OK and my app looks good on different mobile size, But recently I've been wondering if this is a right way and how this can effect my app, what is the best way to write a responsive app?
you can create separate resource files for the separate screen sizes by adding dimension qualifier to your resource directory. This will make your resource directory screen-size-dependent. This will provide you separate files for separate screen sizes like values-ldpi, values-hdpi, dimens-mdpi.... etc.
You can have a brief idea by having a look on this,
https://developer.android.com/guide/practices/screens_support.html
You might have a try first... or you can try this . Hope this helps!
You can make a responsive app by using constrain layout, using guidelines, and can use qualifiers.
Using a qualifier developer can make a different screen for different qualifiers.
eg: For landscape, we can make different layout
For better understanding, you can refer: documentation for responsive screen
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 .
I am switching from web design to android design. Usually website design is based on the 'grid system' eg. 12 columns, 16 columns and etc. The grid system helps organize the layout and also works well with the responsive design, if the columns are set as the percentage of the screen width. However, when i start learning android, I didnt see anyone talking about the grid system for Android. I am wondering if android developers just dont use such grid system or there are other alternatives?
There is GridView.
and GridLayout.
Both have been introduced from different API levels - check your minSdk version.
Depending on your requirement, you can apply a table layout or implement a custom layout.
Go through these docs
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.
I want to design android game program!
i use android DroidDraw program design UI view(Only 2.7" size)
absolutelayout.linearlayiut.tablelayout have tried
However, the components designed address will change with different resolutions
how do design to achieve what I want?
I'm not sure what you're asking, but you may try and peruse Supporting Multiple Screens for a taste of "The Android Way".