Android Build a Simple Android App Creating the Screen Layout Adding a TextView

The app's layout on my phone is not identical to the one in Android Studio.

I run the app on my Galaxy s6 edge and the "Ants stretch when they wake up in the morning." text is on top of the "Did you know?" text (They are both where the "Did you know?" should be). In Android Studio it looks perfect. does someone know what can be the problem? Thanks in advance!

Your Textview which has the "Did you know" text could have been set to be below the "Ants stretch when they wake up in the morning." TextView in your XML code. Please post your XML code here so I can check

Thank you but now I just write the XML myself because I have been told that drag and drop is deceptive. I am using linear layout so now it can not happen.

2 Answers

Jason Wiram
PRO
Jason Wiram
Pro Student 38,630 Points

Things may appear differently in different emulators and/or devices because the screen size, resolution, pixel density, etc may vary. The idea of setting items relative to each other in a relative layout will prevent the overlapping you mentioned. There are times when you may have to adjust the size of items, fonts, etc to make them play nice with all devices. Relative layouts are very powerful in these cases but do take some practice.

I know. the problem was no layout was declared and I understood it only after I wrote everything in linear layout and in this app we don't use any special abilities of the relative layout so I didn't change it.