从任何活动打开边栏应用程序启动 [英] Open Side bar app launcher from any activity

查看:119
本文介绍了从任何活动打开边栏应用程序启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来Android的发展。我期待在创建一个示例启动应用程序,以取代Android的默认启动程序。我创造了这个发射器。但我现在面临几个问题:
 1.在应用程序按钮,点击我显示安装在设备中的所有应用程序。但是,应用程序图标大小不同。我试着给它们设置的最大高度和宽度,但仍问题仍然存在。
 2.该发射器还包括侧边栏。如果我的主屏幕上,我能够从左侧滑动到右得到这个酒吧。但是,当我点击应用按钮,开始新的活动,以显示安装在设备的应用程序,现在如果我尝试带回侧边栏这个屏幕上,它不会工作。这意味着,边栏被绑定到主屏幕。如何使从任何地方访问这个从应用程序列表画面或任何其他应用程序的屏幕。

I am new to the Android Development. I am looking at creating a sample launcher application to replace android default launcher. I have created this launcher. But I am facing couple of problems: 1. On click of Apps button I am showing all the apps installed on device. But app icons are of different size. I tried setting max height and width for them but still problem persists. 2. This launcher also includes side bar. If I am on home screen, I am able to slide from left to right to get this side bar. But when when I click on apps button, which starts new activity to show apps installed on device, now if I try to bring back side bar on this screen, it will not work. That means, side bar is tied to home screen. How to make this accessible from anywhere, from app list screen or from any other apps screen.

我想这些都是常见的问题,但我找不到这样的服务对谷歌。可有人请帮忙吗?

I guess these are common issues, but I couldn't find help on this on google. Can somebody please help?

谢谢,
KAILAS

Thanks, Kailas

推荐答案

最后我能解决这个问题。

Finally I was able to resolve this problem.


  1. 应用程序图标大小

  1. App Icon Size


  • 在XML,其中ImageView的定义,指定layout_width和layout_height为app_icon_size。

ImageView的
        机器人:ID =@ + ID / item_app_icon
        机器人:layout_width =@安卓扪/ app_icon_size
        机器人:layout_height =@安卓扪/ app_icon_size
        机器人:layout_alignParentLeft =真正的

ImageView android:id="@+id/item_app_icon" android:layout_width="@android:dimen/app_icon_size" android:layout_height="@android:dimen/app_icon_size" android:layout_alignParentLeft="true"

花絮:我不知道,如果它是一个黑客或做这个正确的方式。我跟着这个方法:
我用的窗口管理器来承载侧边栏布局。而使用窗口布局PARAMS保持这个窗口始终在最前面任何其他应用程序。边栏的布局也不过是绘图布局在滑动进出带有这种布局在默认情况下。

Sidebar: I am not sure if it is a hack or right way to do this. I followed this approach: I used window manager to host sidebar layout. And used window layout params to keep this window will always be on top any other application. Sidebar layout is nothing but a Drawing Layout to sliding it in and out comes with this layout by default.

WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
       // Shrink the window to wrap the content rather than filling the screen
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT,
        // Display it on top of other application windows, but only for the current user
        WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        // Dont let it grab input focus
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        // Make underlying application window visible through any transparent parts
        PixelFormat.TRANSLUCENT
); drawingLayout = (CustomDrawerLayout) inflater.inflate(R.layout.activity_sidebar, null);
listView = (ListView) drawingLayout.findViewById(R.id.left_drawer);
drawingLayout.setDrawerShadow(R.mipmap.drawer_shadow, GravityCompat.START);
drawingLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
    @Override
    public void onDrawerOpened(View drawerView) {
        super.onDrawerOpened(drawerView);
        WindowManager.LayoutParams newParams = new WindowManager.LayoutParams();
        newParams.copyFrom(params);
        newParams.width = 150;
        windowManager.updateViewLayout(drawingLayout, newParams);
    }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            windowManager.updateViewLayout(drawingLayout, params);
        }

    });

    loadApps(((View) drawingLayout).getContext());
    loadListView(((View) drawingLayout).getContext());
    addClickListener(((View) drawingLayout).getContext());
    windowManager.addView(drawingLayout, params);


这是为我工作正常。但是还是我不知道正确的解决了这一点。如果您有什么更好的方法,请让我知道。谢谢!

This is working for me as expected. But still I am not sure about right solution to this. If you have any better approach, please let me know. Thanks!!

这篇关于从任何活动打开边栏应用程序启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆