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_weightandandroid:weightSumto achieve the proportions you are wanting. Then it should scale itself based on the device without needing any different xml files.