可以在桌面上启用标题栏但不能在手机上启用吗?

时间:2011-09-15 19:01:51

标签: android-ui android

我有一个应用程序,我正在尝试使更多的平板电脑兼容。在手机版本中我将主题设置为无标题栏我认为在手机上看起来最好。唯一的问题是在Android 3.0中,菜单按钮被移动到标题栏(操作栏)。我想知道是否有可能在平板电脑上有一个标题栏,但仍然没有在手机上的标题栏。任何帮助都会很棒。

由于

1 个答案:

答案 0 :(得分:1)

Google I/O app source中有一种检测平板电脑的方法,如下所示:

public class UIUtils {

    public static boolean isHoneycomb() {
        // Can use static final constants like HONEYCOMB, declared in later versions
        // of the OS since they are inlined at compile time. This is guaranteed behavior.
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
    }

    public static boolean isHoneycombTablet(Context context) {
        // Can use static final constants like HONEYCOMB, declared in later versions
        // of the OS since they are inlined at compile time. This is guaranteed behavior.
        return isHoneycomb() && (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK)
                == Configuration.SCREENLAYOUT_SIZE_XLARGE;
    }
}

在您的活动中,您只需致电

即可
if (!UIUtils.isHoneycombTablet(this)) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
}
相关问题