当前位置: 首页>>代码示例>>Java>>正文


Java WindowManager.addView方法代码示例

本文整理汇总了Java中android.view.WindowManager.addView方法的典型用法代码示例。如果您正苦于以下问题:Java WindowManager.addView方法的具体用法?Java WindowManager.addView怎么用?Java WindowManager.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.WindowManager的用法示例。


在下文中一共展示了WindowManager.addView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addWindow

import android.view.WindowManager; //导入方法依赖的package包/类
static void addWindow(Application app) {
    activityLifecycleObservable = new ActivityLifecycleObservable();
    activityTaskView = new ActivityTaskView(app);
    activityTaskView.setObservable(activityLifecycleObservable);

    qhandler = new QueueHandler();

    WindowManager windowManager = (WindowManager) app.getSystemService(Context.WINDOW_SERVICE);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams();
    params.type = WindowManager.LayoutParams.TYPE_PHONE;
    params.format = PixelFormat.RGBA_8888;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
    params.width = WindowManager.LayoutParams.WRAP_CONTENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;
    params.y = app.getResources().getDisplayMetrics().heightPixels;
    windowManager.addView(activityTaskView, params);

    app.registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
}
 
开发者ID:rome753,项目名称:ActivityTaskView,代码行数:22,代码来源:ActivityTask.java

示例2: add

import android.view.WindowManager; //导入方法依赖的package包/类
public static void add(Activity activity) {
    WindowManager manager = ((WindowManager) activity
            .getApplicationContext()
            .getSystemService(Context.WINDOW_SERVICE));

    WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags =
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            // Enable the notification to receive touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            // Draw over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height = (int) (50 * activity.getResources().getDisplayMetrics().scaledDensity);
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    StatusBarOverlay view = new StatusBarOverlay(activity);

    manager.addView(view, localLayoutParams);
}
 
开发者ID:ngocdaothanh,项目名称:cordova-plugin-unswipable-android-status-bar,代码行数:24,代码来源:StatusBarOverlay.java

示例3: showScreensharingBar

import android.view.WindowManager; //导入方法依赖的package包/类
private void showScreensharingBar(boolean show) {
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (show) {
        mScreensharingBar = new ScreenSharingBar(MainActivity.this, this);

        //add screensharing bar on top of the screen
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_APPLICATION_PANEL,
                0 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.LEFT | Gravity.TOP;
        params.x = 0;
        params.y = 0;


        wm.addView(mScreensharingBar, params);
    } else {
        wm.removeView(mScreensharingBar);
        mScreensharingBar = null;
    }
}
 
开发者ID:opentok,项目名称:accelerator-sample-apps-android,代码行数:24,代码来源:MainActivity.java

示例4: addToWindow

import android.view.WindowManager; //导入方法依赖的package包/类
private void addToWindow() {
    if (this.notificationBarView.getParent() == null) {
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        Point windowSize = new Point();
        windowManager.getDefaultDisplay().getSize(windowSize);
        int widthMeasureSpec = MeasureSpec.makeMeasureSpec(Math.min(windowSize.x, windowSize.y), 1073741824);
        int heightMeasureSpec = MeasureSpec.makeMeasureSpec(windowSize.y, Integer.MIN_VALUE);
        this.notificationBarView.setLayoutParams(new LayoutParams(-1, -2));
        this.notificationBarView.measure(widthMeasureSpec, heightMeasureSpec);
        int width = this.notificationBarView.getMeasuredWidth();
        int height = this.notificationBarView.getMeasuredHeight();
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, 2010, 16843544, -3);
        params.gravity = 49;
        windowManager.addView(this.notificationBarView, params);
        params = new WindowManager.LayoutParams(width, height, 2010, 16843528, -3);
        params.gravity = 49;
        windowManager.addView(this.notificationTouchListener, params);
        Log.d(TAG, "Added overlay views to display");
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:21,代码来源:OverlayNotificationController.java

示例5: showLoading

import android.view.WindowManager; //导入方法依赖的package包/类
public static void showLoading(Context context, int rgb){
    if (sShowing){
        return;
    }
    sManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    if (sLoading == null){
        sLoading = (WinProgress) LayoutInflater.from(context)
                                               .inflate(R.layout.loading, null);
    }
    if (rgb != 0){
        sLoading.setColor(rgb);
    }
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.height = (int) DisplayUtil.dp2px(64);
    layoutParams.width = (int) DisplayUtil.dp2px(64);
    layoutParams.format = PixelFormat.TRANSLUCENT;
    layoutParams.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    sShowing = true;
    sManager.addView(sLoading , layoutParams);
    sLoading.show();
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:26,代码来源:Loading.java

示例6: addInboxBodyToWindow

import android.view.WindowManager; //导入方法依赖的package包/类
void addInboxBodyToWindow(int windowType) {
    if (windowType == 2010 || windowType == 2007) {
        Log.d(TAG, "add Tray()");
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        LayoutParams params = new LayoutParams(-2, -2, windowType, 16843544, -3);
        params.gravity = 51;
        params.width = -1;
        params.height = -1;
        params.x = (int) FAR_AWAY;
        params.y = 0;
        windowManager.addView(this.shadeInboxBody, params);
        this.shadeInboxBody.setVisibility(View.INVISIBLE);
        return;
    }
    Log.d(TAG, "Unrecognized Window Type: addInboxBodyToWindow()");
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:17,代码来源:ShadeViewManager.java

示例7: createView

import android.view.WindowManager; //导入方法依赖的package包/类
/**
 * 创建浮层view
 *
 * @param coverView 被覆盖的view,用于计算浮层位置
 * @param scale     缩放比例
 */
public void createView(View coverView, float touchRawX, float touchRawY, float scale) {
    currTouchedView = createFloatView(coverView);

    manager = (WindowManager) currTouchedView.getContext().getSystemService(
            Context.WINDOW_SERVICE);
    params = initParams(currTouchedView);
    params.width = (int) (coverView.getWidth() * scale);//窗口的宽和高
    params.height = (int) (coverView.getHeight() * scale);
    int[] location = getLocation(coverView);
    params.x = location[0];//窗口位置的偏移量
    params.y = location[1];
    manager.addView(currTouchedView, params);

    offsetX = (int) (touchRawX - location[0]);
    offsetY = (int) (touchRawY - location[1]);
}
 
开发者ID:free46000,项目名称:MultiItem,代码行数:23,代码来源:DragFloatViewHelper.java

示例8: onCreate

import android.view.WindowManager; //导入方法依赖的package包/类
@Override
public void onCreate() {

    myView = new MyFilterView(this);

    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(myView, mParams);

    super.onCreate();
}
 
开发者ID:webianks,项目名称:Crimson,代码行数:20,代码来源:ScreenFilterService.java

示例9: onCreate

import android.view.WindowManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    appContext = getApplicationContext();
    boolean canDraw = true;
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // If the version requires a permission to draw over apps,
        canDraw = Settings.canDrawOverlays(appContext);
    }
    if (canDraw) {
        // If Forge is allowed to draw over other apps
        // Close the notifications status bar
        Intent closeStatusBarIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        appContext.sendBroadcast(closeStatusBarIntent);
        // Load the current account
        account = CurrentManager.loadCurrentAccount(appContext);
        // Get the window manager
        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        // Get the layout inflater
        LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        // Create the view from the forge overlay layout
        view = layoutInflater.inflate(R.layout.forge_overlay, null);

        setUpEditTexts();
        setUpButtons();

        // Set up window manager parameters
        WindowManager.LayoutParams params;

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // If the device is version Oreo or greater
            params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                    PixelFormat.TRANSPARENT);
        } else {
            // If the device is pre-Oreo
            params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.TYPE_PHONE,
                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                    PixelFormat.TRANSPARENT);
        }
        params.gravity = Gravity.CENTER;

        // Display the view over the app
        windowManager.addView(view, params);
    } else {
        this.stopSelf();
    }
}
 
开发者ID:jthomperoo,项目名称:Forge,代码行数:55,代码来源:OverlayService.java

示例10: showWindow

import android.view.WindowManager; //导入方法依赖的package包/类
private void showWindow() {
    //获取系统服务
    wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    //获取布局参数
    layoutparams = new WindowManager.LayoutParams();
    //定义宽高
    layoutparams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutparams.height = WindowManager.LayoutParams.MATCH_PARENT;
    //定义标记
    layoutparams.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
    //定义格式
    layoutparams.format = PixelFormat.TRANSLUCENT;
    //定义类型
    layoutparams.type = WindowManager.LayoutParams.TYPE_PHONE;
    //加载布局
    mView = (DispatchLinearLayout) View.inflate(getApplicationContext(), R.layout.sms_item, null);

    tv_phone = (TextView) mView.findViewById(R.id.tv_phone);
    tv_content = (TextView) mView.findViewById(R.id.tv_content);
    btn_send_sms = (Button) mView.findViewById(R.id.btn_send_sms);
    btn_send_sms.setOnClickListener(this);

    //设置数据
    tv_phone.setText("发件人:" + smsPhone);
    L.i("短信内容:" + smsContent);
    tv_content.setText(smsContent);

    //添加View到窗口
    wm.addView(mView, layoutparams);

    mView.setDispatchKeyEventListener(mDispatchKeyEventListener);
}
 
开发者ID:lijizhi,项目名称:studydemo,代码行数:34,代码来源:SmsService.java

示例11: initPosition

import android.view.WindowManager; //导入方法依赖的package包/类
private void initPosition() {
    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    mParams.gravity = Gravity.TOP | Gravity.LEFT;
    mParams.x = 0;
    mParams.y = 150;

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(mFloatingView, mParams);
}
 
开发者ID:gokhanoguz,项目名称:FloatingWidget,代码行数:16,代码来源:FloatingWidgetService.java

示例12: show

import android.view.WindowManager; //导入方法依赖的package包/类
public void show() {
	if (mNextView != null) {
		wm = (WindowManager) mContext
				.getSystemService(Context.WINDOW_SERVICE);
		WindowManager.LayoutParams params = new WindowManager.LayoutParams();
		params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
		params.height = WindowManager.LayoutParams.WRAP_CONTENT;
		params.width = WindowManager.LayoutParams.WRAP_CONTENT;
		params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
				| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
				| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
		params.format = PixelFormat.TRANSLUCENT;
		params.y = dip2px(mContext, 64);
		params.type = WindowManager.LayoutParams.TYPE_TOAST;
		wm.addView(mNextView, params);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				if (mNextView != null) {
					wm.removeView(mNextView);
					mNextView = null;
					wm = null;
				}
			}
		}, mDuration);
	}
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:29,代码来源:MyToast.java

示例13: showFloater

import android.view.WindowManager; //导入方法依赖的package包/类
private void showFloater() {

        if (isShown) {
            return;
        }

        isShown = true;

        TextView floater = new TextView(this);
        floater.setBackgroundColor(Color.BLACK);
        floater.setText(TAG);
        floater.setTextColor(Color.WHITE);

        floater.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MainActivity.this, TAG, Toast.LENGTH_LONG).show();
            }
        });

        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

        WindowManager.LayoutParams lph = new WindowManager.LayoutParams();
        lph.type = WindowManager.LayoutParams.TYPE_TOAST;
        lph.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        lph.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        lph.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        lph.width = WindowManager.LayoutParams.MATCH_PARENT;
        lph.height = 100;
        lph.format = PixelFormat.RGBA_8888;
        lph.gravity = Gravity.TOP;

        wm.addView(floater, lph);
    }
 
开发者ID:zhangjianli,项目名称:StallBuster,代码行数:35,代码来源:MainActivity.java

示例14: init

import android.view.WindowManager; //导入方法依赖的package包/类
void init() {
    WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    Point size2 = new Point();
    display.getCurrentSizeRange(size, size2);
    this.screenWidth = size.x;
    this.screenHeight = size2.x;
    this.statusBarHeight = size2.x - size2.y;
    LayoutParams params = new LayoutParams(-2, -2, 2007, 16843544, -3);
    params.gravity = 51;
    params.width = -1;
    params.height = -1;
    params.x = this.FAR_AWAY;
    params.y = 0;
    LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.renderView = new RelativeLayout(this.context);
    this.trashFooter = (ViewGroup) inflater.inflate(R.layout.swipe_relocation_trash_footer, null);
    this.trashCan = this.trashFooter.findViewById(R.id.swipe_relocator_trash);
    this.swipeTab = (YettiTabLayout) inflater.inflate(R.layout.yetti_tab_layout, null);
    this.swipeTab.animate().setDuration(0).alpha(0.0f);
    windowManager.addView(this.renderView, params);
    this.renderView.addView(this.swipeTab, -2, -2);
    this.renderView.addView(this.trashFooter, -1, -1);
    resetTrash();
    setupGestureDetector();
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:28,代码来源:SwipeTabViewRelocationController.java

示例15: onCreate

import android.view.WindowManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    
    ctx = this;
    wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
   
    overlayedButton = new FloatingButton(ctx)
                    .setColor(MyColor.BLUE.getColor())
                    .setDrawable((BitmapDrawable) getResources().getDrawable(R.drawable.ic_list_white_48dp))
                    .setStroke(Utils.dip2px(ctx, 3) , MyColor.BLUE.getColorAccent())
                    .setPadding(Utils.dip2px(ctx, 13), Utils.dip2px(ctx, 10), Utils.dip2px(ctx, 13), Utils.dip2px(ctx, 10))
                    .show();
    overlayedButton.setOnTouchListener(this);
    
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(Utils.dip2px(ctx, 50), Utils.dip2px(ctx, 50), WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.TOP;
    params.x = 0;
    params.y = 0;
    wm.addView(overlayedButton, params);

    FloatingView = new View(this);
    WindowManager.LayoutParams FloatingViewParams = new WindowManager.LayoutParams(Utils.dip2px(ctx, 50), Utils.dip2px(ctx, 50), WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
    FloatingViewParams.gravity = Gravity.LEFT | Gravity.TOP;
    FloatingViewParams.x = 0;
    FloatingViewParams.y = 0;
    FloatingViewParams.width = 0;
    FloatingViewParams.height = 0;
    wm.addView(FloatingView, FloatingViewParams);

}
 
开发者ID:AstinPE,项目名称:FloatingApps,代码行数:32,代码来源:AlwaysOnTopService.java


注:本文中的android.view.WindowManager.addView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。