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 .
Related
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.
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.
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.
I am trying to create a calculator app and I've been having problems with the xml layout.
Due to the amount of button even though I use dp's to determine the size of each button from screen to screen the result varies...
Am i supposed to create the layout in java so I can get the screen dimensions?? if so can I have an example?
You can design the layout file and then make a few versions of it with different sized buttons. put them in res/layout-small/, res/layout-large/, and res/layout-normal/. The system will pull the proper xml file according to what size display the device has.
Another option is to try to design the layout with specifying a size in dp, instead use android:layout_weight and android:weightSum to achieve the proportions you are wanting. Then it should scale itself based on the device without needing any different xml files.
My layout has TextViews that need to be in a certain position on the screen in that layout. If I have a layout that displays how I want it on say a 10" tablet, how can I get it to display the same on say a phone screen and keep it relative to what it would be on the tablet?
meaning how can I get both the tablet and the phone to look exactly the same xml layout views without changing them manually? Is there an xml attribute I can use that will scale the view correctly to the device screen?
This can help you:
Supporting multiple screens