我正在 Android 中创建一个应用程序。最初我只为智能手机制作它,但现在我希望同样的应用程序能够支持 Android 平板电脑。问题在于缩放。它没有缩放到平板电脑屏幕的大小。我使用了 LinearLayout,高度和宽度作为 fill_parent。
最佳答案
您想阅读本手册的这一部分:http://developer.android.com/guide/practices/screens_support.html
(请务必阅读!)
但是您可以尝试在 androidmanifest.xml 中添加屏幕支持:
The platform also provides a manifest element, whose attributes android:smallScreens, android:normalScreens, android:largeScreens, and android:xlargeScreens let you specify what generalized screen sizes your application supports.
让它看起来像这样:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
...
</manifest>
screen-support page还指出了这一点:(emph 我的)
Maintain compatibility with existing devices by leaving your application's android:minSdkVersion attribute as it is. You do not need to increment the value of the attribute to support new devices and multiple screens. Extend compatibility for Android 1.6 (and higher) devices by adding a new attribute — android:targetSdkVersion — to the uses-sdk element. Set the value of the attribute to "4". [To support xhdpi and xlarge screens, set the value to "9".] This allows your application to "inherit" the platform's multiple screens support, even though it is technically using an earlier version of the API.
因此,对于最一般的情况来说,更新 minSdkVersion 的解决方案似乎是不需要的。如果您将“3”作为适合您情况的 minSdkVersion,请保留该值,但添加 targetSdkVersion 以实现兼容性。
关于Android 智能手机应用程序支持 Android 平板电脑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4955375/