Android stretches the layout file instead of loading the correct file in the res folders

一曲冷凌霜 提交于 2020-01-17 02:43:26

问题


I have a handset version of an activity and a tablet version of the same activity. My handset version is res/layout/activity.xml while my 7' tablet version is res/layout-sw600dp/activity.xml

The thing is that when I run the app in a 7' tablet, not only does it not load the xml file in res/layout-sw600dp, but it displays a stretched version of the layout in the res/layout folder. So, everything from buttons, images, as well as the action bar itself is simply stretched and distorted to fill the whole screen (much the same way an iPad displays the 2X version of an iPhone app).

I was using Android Studio and it was working fine, but I had to switch to Eclipse for reasons which aren't relevant, so I suspect it might be something related to Eclipse's configuration, but it's just a wild guess.

I've never had this issue before. Has anyone ever experienced this and found a solution? Thanks.

pd. If I use Eclipse's layout editor and select "Preview all sizes", it actually loads the correct xml into the 7' and the 10' previews.


回答1:


Found a solution. What was causing this weird behavior is that I was missing the following attributes in my AndroidManifest.xml file:

<uses-sdk android:minSdkVersion="9"
      android:targetSdkVersion="19"
      android:maxSdkVersion="19" />


来源:https://stackoverflow.com/questions/25277330/android-stretches-the-layout-file-instead-of-loading-the-correct-file-in-the-res

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