Android 智能手机应用程序支持 Android 平板电脑

标签 android tablet

我正在 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/

相关文章:

layout - 如何确定自适应网页设计的常见设备的常见视口(viewport)尺寸(不是屏幕尺寸)?

android - Android 平板电脑和手机使用哪种资源结构?

android - 使用 SupportToolbar 进行手机布局,使用独立操作栏进行平板电脑布局

android - 覆盖 ?android :attr/textAppearanceSmall 的字体大小

java - 通过通用方法访问 Java 中的各种枚举

android - 如何在 Android 中阻止特定的 url

android - 将现有应用程序转换为使用 Fragments

java - 在 Activity 之间传输 TextView 数据?

android - 从android中的字节数组中读取EXIF数据

css - 在方向更改时禁用 css 动画