ConstraintLayout to build responsive app - android

i'm working on an android app , trying to make it responsive in different screen sizes, so i'm using constraintlayout . But i had a problem when i test it in a tablet in mode portrait (vertical) there is so much space in the bottem i've tried to work with PercentRelativeLayout(supports percentage based margin and dimensions for Views) it has a good result but it's deprecated. Any idea please ?

You could also use ConstraintLayout Chaining to connect your Views into a group and then you can center, expand, pack these into the available space as desired. This layout will change dynamically based on the screen size and orientation.
Using alternate layouts as mentioned (layout-sw600dp) is also a good idea. The system will automatically use this layout instead of the default layout. 600dp is a good display width to make the breakpoint for tablets.

Related

How can I make widgets adjust their size to look the same on every device?

I was wondering how to make my interface's TextViews, ImageViews, Margins, etc... look the same on all devices no matter if I'm using it on a phone or a tablet. I was told that using fragments would help, but I don't seem to understand. Sorry for the babyish question...
You can use constraint layout and set the widget's height and width according to the screen's width and height. Or you can have different layout files for diffrent screen densities.

how to design PlayerActivity layout in each inch device

I want to be my Player Activity in the way that main things show user(such as play button ,rewind,forward ,cover ,date) and other things show when user scroll activity in all device with each inch size.I do that in way that I get screen height of device in pixel and give to relative layout programmatically and other things put below of this relative layout.Is that true?
if you ask about how to support different screen size it is devices
you should not add any layout_width or layout_height fixed size
and use weights in linear layout
Use best practices in dimensions use “dp” and in text size use “sp”.
Use nested layouts for better control and to make your activity xml less complex
You can make two designs one for big screens and one for small ones.
it is for layout , I hope it will help you .

Layout of a android application

I'm working on the layout of an android application. But I have a question about the layout. Once i have created a layout and then go to another screen (for instance 4 inches to 5 inches) all my buttons and text boxes are messed up..
Is there a method to make everything static, so that my layout works on every mobile phone..
What kind of layout are you using, could it be RelativeLayout? that might be your problem in this particular instance.
Anyway, in android there are many screen sizes, each of them you should handle with different layouts depending on orientation, size and density. There is no magic formula as far as I know, but 9-patch images can help a lot. Another thing you should do is make sure that you understand how match_parent and wrap_content values work for height and width.
Check this out: Suppoting different screens
You have to create folders for different types of screens take a look at android developers training
This document contains everything you need.
Instead of having everything fixed, it shows how to design a layer that adapts to the various screens you may encounter.

Designing for different screen - Android

I want my app to run perfectly on different screen sizes, Galaxy Tab 2, Galaxy Note 800 and Galaxy Note 2.
However, my app is fairly complex and I can't use wrap_content or fill_parent at all places. I've tried using layout_weight but even that couldn't be used with RelativeLayout.
Is there any smart way of resizing your screen components depending upon screen size other than making different layouts all together as suggested in Android documentation and is there any way to use layout_weight in RelativeLayout?
Thanks!
You can use TableLayout and in that TableRow. I have preferred these to RelativeLayout in one of my project because RelativeLayout does not support weight property as you said.
Its true you cannot use weight with Relative Layout. If you want to make sure your layout runs perfectly for every device. You must use Nested LinearLayouts with views and do that in weight your UI will be perfect if you have good resolution images for every device.
Moreover in RelativeLayout complex layout can't be perfect as you cannot use weight and sometimes images may get skew or stretch .
Of course using Nested LinearLayouts with views do increase some extra lines but this is the only perfect solution.
I found an efficient way round.
Instead of hard coding dimensions in layout I used a reference of them in Resources/values/dimensions.xml. So, for different screen sizes I simply made different dimension file in Resources, thereby reducing complexity and avoided making separate layouts for all screen sizes.

How to Resize screen of Android

I am developing an application for whole android devices. But resolation of screens are different and that is the biggest problem how it looks. So, I want to make resizing controls and also I used absolutelayout but It is still same.. I give value to controls as dp ..
How can I solve this problem ?
You don't resize the screen of an android device - you make your app instead work with the various screen sizes.
The relevant docs are here.
You cannot hardcode the dimensions of your layout and expect it to work on every screen size. And there is no method which automatically does it unless you write it.
You might want to change your approach, use Relative Layout or Linear Layout instead and use values like fill_parent and wrap_content while designing your layout.
Another approach Android developers follow is use different resource files for different screen sizes and Android loads them automatically at runtime.
Refer to this for more info on how to work with different screen sizes effectively.

Categories

Resources