Android Nexus10不像平板电脑
我的问题是,Android Studio Nexus 10中模拟的操作不像手机。我尝试了两种方法来检测设备是平板电脑还是手机:Android Nexus10不像平板电脑,android,android-emulator,tablet,Android,Android Emulator,Tablet,我的问题是,Android Studio Nexus 10中模拟的操作不像手机。我尝试了两种方法来检测设备是平板电脑还是手机: public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configu
public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
这里的变体是什么
当Nexus7和其他平板电脑使用时,两者都不适用于Nexus10。可能是模拟器的问题,我不知道。请帮帮我。这是药片测定的老方法。为了指出出了什么问题,您没有检查设备是否与n10一样大。这种过时方式的更正确版本是: 从 但请遵循以下答案,而不是这一点:
public static boolean isTablet(Context context) {
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
return (xlarge || large);
}