简体   繁体   中英

How can I set a standard layout for every device in android studio

I was making an app and when I imported it to my phone I noticed that all the images and text had been sent to different places. Same with my tablet. Is there a way to keep that I can keep everything in the layout the same regardless of the screen size? Thanks

why you don't try to use the constraint layout , its the best choice , and for picture use SVG , to avoid resize problems ,

check : https://developer.android.com/training/constraint-layout/

and for SVG : https://developer.android.com/guide/topics/graphics/vector-drawable-resources

and also this tools helps you to convert the svg to vector drawable : http://inloop.github.io/svg2android/

Yes, There is. You were working on DPs and i think it was a low one selected from right of the design window. But there is a "weight" attribute. You can make perfect fitting apps by using it.

"weight" basically using for dividing layouts on equal sizes. It makes fit all devices better then before because dp can be change but percent cannot. You can find more info about weight in here..

Using layout_weight

You can use LinearLayout and never give height in dp's (density pixels) because every phone and tablets have different resolutions and according to dp you have given they take place on screen. If you are using LinerLayout always use match_parent or wrap_content and if you want some elements in same row (horizontally) use layout-weight property . Using match_parent , wrap_content , layout-weight these will set the elements properly on the screen irrespective of phone,tablet etc..

hope it will solve your problem !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM