Android 长按桌面显示菜单的代码

packages\apps\Launcher3\src\com\android\launcher3\views\OptionsPopupView.java

显示的具体菜单

public static void showDefaultOptions(Launcher launcher, float x, float y) {
        float halfSize = launcher.getResources().getDimension(R.dimen.options_menu_thumb_size) / 2;
        if (x < 0 || y < 0) {
            x = launcher.getDragLayer().getWidth() / 2;
            y = launcher.getDragLayer().getHeight() / 2;
        }
        RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize);

        ArrayList options = new ArrayList<>();
        options.add(new OptionItem(R.string.wallpaper_button_text, R.drawable.ic_wallpaper,
                ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker));
        options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
                ControlType.WIDGETS_BUTTON, OptionsPopupView::onWidgetsClicked));
        options.add(new OptionItem(R.string.settings_button_text, R.drawable.ic_setting,
                ControlType.SETTINGS_BUTTON, OptionsPopupView::startSettings));

        show(launcher, target, options);
    }

会弹出一个选择列表:具体的选择列表在

frameworks\base\core\java\com\android\internal\app\ResolverActivity.java

设置系统导航栏透明可以使用

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

你可能感兴趣的:(android,python,开发语言)