简体   繁体   English

如何在 Android Studio 中为手机和平板电脑创建项目?

[英]How can I create a project for phones and tablets in Android Studio?

How can I create a project in Android Studio for phones and tablets, where the APK on the Play Store is the same for both?如何在 Android Studio 中为手机和平板电脑创建项目,其中 Play 商店中的 APK 对两者都相同?

I am using build variants with build flavors, but there are two APKs for every device.我正在使用具有构建风格的构建变体,但每个设备都有两个 APK。

You can just approximate if it's a tablet or not by checking the screendimension.您可以通过检查屏幕尺寸来估算它是否是平板电脑。 If the app uses XLARGE or LARGE display dimensions, it could be a tablet or a "big" phone.如果应用程序使用 XLARGE 或 LARGE 显示尺寸,则它可能是平板电脑或“大”手机。

You can get informations about that with something like this:您可以通过以下方式获取相关信息:

if(getResources().getConfiguration().screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE 
|| getResources().getConfiguration().screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
    //doSomething
}

You can test which of these ones is the better one for you.您可以测试其中哪一个更适合您。

more reference:更多参考:

Designing Android apps for tablets 为平板电脑设计 Android 应用

Different GUI on phone and tablet, but same app problem 手机和平板电脑上的 GUI 不同,但应用程序问题相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用用户代理标头以不同方式检测Android手机和Android平板电脑? - How can I detect Android phones and Android tablets differently using the user agent header? 我可以使用相同的插件为Android手机和平板电脑开发吗? - Can I develop for Android Phones and Tablets using the same plugin? 如何在Android上指定仅适用于手机或平板电脑的活动 - How to specify Activities that are only for phones or tablets on Android 如何仅将Android设置为手机/平板电脑? - How to set android for phones/tablets only? 在无root用户的情况下,如何以编程方式控制Android OS手机和平板电脑中的内部数字电视调谐器? - How can I control, programmatically, the internal digital tv tuner in Android OS Mobile Phones, and Tablets, in unrooted user case? 平板电脑和手机上的Android图像 - Android image on tablets and phones 我如何在Android Studio中创建Android示例项目 - How i can create Android Sample Project in Android Studio 同一款Android应用程序可以用于手机,平板电脑和Google TV吗? - Can the same Android App be used for mobile phones, tablets and Google TV? Android应用程式可在手机中运作,但不适用于平板电脑 - Android app working in phones but not in tablets 智能手机和平板电脑的Android应用程序 - Android Apps for Smart Phones & Tablets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM