Android Studio Designer displaying widgets & fragments differently than my phone

纵饮孤独 提交于 2019-12-20 06:26:26

问题


I'm having problems with how items appear in the Android Studio Designer and my phone. The first problem is that widgets & fragments appear differently in the designer/emulator than on my phone. I have tried lowering the resolution in the designer to test other device resolutions but it still appears differently on my phone despite the resolutions being relatively the same.

Designer view:

http://i.imgur.com/5kZKFDd.png

HTC Desire 510:

http://i.imgur.com/SqDiyBy.png

The designer view is using the Nexus S's resolution which is smaller than my phone's resolution, yet the items still appear differently. I am in fact using RelativeLayout.

The other problem is that if you noticed, the button and text appears differently in the designer/emulator than on my phone. When I click the button on my phone, there is no button down effect, yet in the emulator, the effect is present. This is problematic because I want my designs to be consistent across all devices.


回答1:


The designer/emulator use the official frameworks of android, while Some mobile device manufacturer may modify some appearance of widgets in frameworks, so the "View" you see in designer may be different from what you see in real devices, even different devices have different appearance for some widgets.

Support the real device have not modified widgets appearance in frameworks, then you can expect them have the same appearance with designer/emulator. One thing to notice, Android studio designer renders "Views" using some theme, you can specify the theme using "tools:context" attribute or select one in options, for example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal"
          tools:context=".MainActivity"/>



来源:https://stackoverflow.com/questions/29000884/android-studio-designer-displaying-widgets-fragments-differently-than-my-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!