简体   繁体   中英

android studio preview and when it works on phone is different

In the Android Studio design preview, my layout fits perfectly on screen. Even when I played it though AVD , it fits well. But when I connect my phone with Android studio and run it, it doesn't fit in my phone screen. It seems like centerCrop is on the whole screen. all layouts have the same problem.

I'm using a Samsung s8+. Preview setting is also Samsung s8+ which Android Studio provides.

At first, I thought that this problem is caused by 18.5:9 ratio of my phone. But in that case, the screen should be cut only at bottom and top. But it seems like centerCrop is enlarging based on the center?

The screenshot on the left is what I see on the preview and on the right is what I see on my physical phone:

Android Studio设计预览与实体手机的屏幕截图

Two Solutions:

  1. Go for Linear layout if you don't bother layout hierarchy and coding style, as it fits for the most number of screens.
  2. The design which you saw in the emulator will not be same in Actual mobile device in all cases. So try to debug your app in actual mobile device and design accordingly.

确保您的自定义仿真器具有与手机相同的设置(Height,Width,RAM)。

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