@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(); }
@Test public void testGetOpacity() throws Exception { BorderDrawable opaque = new BorderDrawable(); opaque.setColor(Color.GREEN); assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE)); BorderDrawable transparent = new BorderDrawable(); transparent.setColor(WXResourceUtils.getColor("#00ff0000")); assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT)); BorderDrawable half = new BorderDrawable(); half.setColor(WXResourceUtils.getColor("#aaff0000")); assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT)); BorderDrawable changeAlpha = new BorderDrawable(); changeAlpha.setColor(Color.RED); changeAlpha.setAlpha(15); assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT)); }
@Nullable private View showKeyguardView (boolean showSettings) { if (Build.VERSION.SDK_INT >= 23) { if (!Settings.canDrawOverlays(mContext)) { if (!showSettings) return null; Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); mContext.startActivity(i); return null; } } View keyguardView = LayoutInflater.from(mContext).inflate(R.layout.layout_keyguard, null); WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(); wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; wmParams.format = PixelFormat.TRANSPARENT; wmParams.flags=WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; wmParams.width=WindowManager.LayoutParams.MATCH_PARENT; wmParams.height= WindowManager.LayoutParams.MATCH_PARENT; mManager.addView(keyguardView, wmParams); mContext.startActivity(new Intent(mContext, KeyguardLiveActivity.class)); return keyguardView; }
public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; }
/** * A factory method to build the appropriate LuminanceSource object based on the format * of the preview buffers, as described by Camera.Parameters. * * @param data A preview frame. * @param width The width of the image. * @param height The height of the image. * @return A PlanarYUVLuminanceSource instance. */ public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { Rect rect = getFramingRectInPreview(); int previewFormat = configManager.getPreviewFormat(); String previewFormatString = configManager.getPreviewFormatString(); switch (previewFormat) { // This is the standard Android format which all devices are REQUIRED to support. // In theory, it's the only one we should ever care about. case PixelFormat.YCbCr_420_SP: // This format has never been seen in the wild, but is compatible as we only care // about the Y channel, so allow it. case PixelFormat.YCbCr_422_SP: return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height()); default: // The Samsung Moment incorrectly uses this variant instead of the 'sp' version. // Fortunately, it too has all the Y data up front, so we can read it. if ("yuv420p".equals(previewFormatString)) { return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height()); } } throw new IllegalArgumentException("Unsupported picture format: " + previewFormat + '/' + previewFormatString); }
private static Bitmap drawable2Bitmap(Drawable drawable) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
public SurfaceViewTemplate(Context context, AttributeSet attrs) { super(context, attrs); mHolder = getHolder(); mHolder.addCallback(this); // 设置Surface在Window(普通视图架构)之上 setZOrderOnTop(true); // 设置色彩格式,半透明 mHolder.setFormat(PixelFormat.TRANSLUCENT); // 设置可获得焦点 setFocusable(true); setFocusableInTouchMode(true); // 设置保持屏幕亮 this.setKeepScreenOn(true); }
private Bitmap drawable2Bitmap(final Drawable drawable) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
private static Bitmap drawable2Bitmap(Drawable drawable) { if (drawable == null) { return null; } // 取 drawable 的长宽 int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); // 取 drawable 的颜色格式 Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; // 建立对应 bitmap Bitmap bitmap = Bitmap.createBitmap(w, h, config); // 建立对应 bitmap 的画布 Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); // 把 drawable 内容画到画布中 drawable.draw(canvas); return bitmap; }
/** * drawable转bitmap * * @param drawable drawable对象 * @return bitmap */ public static Bitmap drawable2Bitmap(final Drawable drawable) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
/** 设置回调 */ protected void setPreviewCallback() { Size size = mParameters.getPreviewSize(); if (size != null) { PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(mParameters.getPreviewFormat(), pf); int buffSize = size.width * size.height * pf.bitsPerPixel / 8; try { camera.addCallbackBuffer(new byte[buffSize]); camera.addCallbackBuffer(new byte[buffSize]); camera.addCallbackBuffer(new byte[buffSize]); camera.setPreviewCallbackWithBuffer(this); } catch (OutOfMemoryError e) { Log.e("Yixia", "startPreview...setPreviewCallback...", e); } Log.e("Yixia", "startPreview...setPreviewCallbackWithBuffer...width:" + size.width + " height:" + size.height); } else { camera.setPreviewCallback(this); } }
private static Bitmap drawable2Bitmap(Drawable drawable) { if (drawable == null) { return null; } int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; Bitmap bitmap = Bitmap.createBitmap(w, h, config); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); drawable.draw(canvas); return bitmap; }
public boolean startCameraPreview(){ try { Camera.Parameters parameters = camera.getParameters(); parameters.setPictureFormat(PixelFormat.JPEG); //parameters.setPictureSize(surfaceView.getWidth(), surfaceView.getHeight()); // 部分定制手机,无法正常识别该方法。 parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);//1连续对焦 setDispaly(parameters, camera); camera.setParameters(parameters); camera.startPreview(); camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。 }catch (RuntimeException e){ Toast.makeText(context, "该手机不支持参数设定", Toast.LENGTH_LONG).show(); } return true; }
TooltipPopup(Context context) { mContext = context; mContentView = LayoutInflater.from(mContext).inflate(R.layout.appcompat_tooltip, null); mMessageView = (TextView) mContentView.findViewById(R.id.message); mLayoutParams.setTitle(getClass().getSimpleName()); mLayoutParams.packageName = mContext.getPackageName(); mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mLayoutParams.format = PixelFormat.TRANSLUCENT; mLayoutParams.windowAnimations = R.style.Animation_CrossPort_Tooltip; mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; }
public void addToWindowManager() { WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams( CANVAS_WIDTH, CANVAS_HEIGHT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); windowLayoutParams.gravity = Gravity.BOTTOM | Gravity.END; mLinearLayout = new LinearLayout(mContext); mLinearLayout.setBackgroundColor(Color.BLACK); mWindowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); mWindowManager.addView(mLinearLayout, windowLayoutParams); TextView textView = new TextView(mContext); textView.setTextColor(Color.RED); textView.setText( String.format("Name: %s \n Code: %s", mPackageInfo.versionName, mPackageInfo.versionCode) ); mLinearLayout.addView(textView); }
private void init() { setEGLContextClientVersion(2); setEGLConfigChooser(8, 8, 8, 8, 16, 0); getHolder().setFormat(PixelFormat.RGBA_8888); setRenderer(this); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); float[] cube = OpenGLUtils.CUBE; mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); mCubeBuffer.put(cube); float[] textureCords = OpenGLUtils.getTextureCords(90, mCameraId == CameraInfo.CAMERA_FACING_FRONT, true); mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); mTextureBuffer.put(textureCords); List<CameraFilter> filters = new ArrayList<>(); filters.add(mCameraInputFilter); filters.addAll(initFilters()); mCameraFilterGroup = new CameraFilterGroup(filters); }
@Override protected void initView() { mSurfaceview = (SurfaceView) findViewById(R.id.surfaceview); mRlTakeVedio = (RelativeLayout) findViewById(R.id.rl_take_vedio); mIvCancel = (ImageView) findViewById(R.id.iv_cancel); mTrpbController = (TimeRoundProgressBar) findViewById(R.id.trpb_controller); mRlConfrmVedio = (RelativeLayout) findViewById(R.id.rl_confrm_vedio); mIvDelete = (ImageView) findViewById(R.id.iv_delete); mIvConfirm = (ImageView) findViewById(R.id.iv_confirm); mDialog = ERecorderActivityImpl.getCreateVedioDialog(getActivity()); mTrpbController.setMax(mRecordTime); SurfaceHolder holder = mSurfaceview.getHolder();// 取得holder holder.setFormat(PixelFormat.TRANSPARENT); holder.setKeepScreenOn(true); holder.addCallback(this); // holder加入回调接口 }
/** * Drawable转换为Bitmap * * @param drawable the drawable * @return bitmap */ public static Bitmap getBitmap(Drawable drawable) { if (drawable == null) return null; if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; } }
private int detectBestPixelFormat() { //Skip check if this is a new device as it will be RGBA_8888 by default. if (isRGBA_8888ByDefault) { return PixelFormat.RGBA_8888; } Context context = getContext(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); //Get display pixel format int displayFormat = display.getPixelFormat(); if ( PixelFormat.formatHasAlpha(displayFormat) ) { return displayFormat; } else { return PixelFormat.RGB_565;//Fallback for those who don't support Alpha } }
protected void showDialog(Context context) { final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int h = getNavbarHeight(context); int w = WindowManager.LayoutParams.MATCH_PARENT; WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(w, h, WindowManager.LayoutParams.TYPE_TOAST, 0, PixelFormat.TRANSLUCENT); layoutParams.gravity = Gravity.BOTTOM; ViewGroup viewGroup; if (mType == LIGHT) { viewGroup = getLightPanel(context); } else { viewGroup = getVolumePanel(context); } if (lightPanel != null && lightPanel.isAttachedToWindow()) { wm.removeView(lightPanel); } if (volumePanel != null && volumePanel.isAttachedToWindow()) { wm.removeView(volumePanel); } wm.addView(viewGroup, layoutParams); }
/** * drawable转bitmap * * @param drawable drawable对象 * @return bitmap */ public static Bitmap drawable2Bitmap(Drawable drawable) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
/** * 创建拖动的镜像 * * @param bitmap * @param downX 按下的点相对父控件的X坐标 * @param downY 按下的点相对父控件的X坐标 */ private void createDragImage(Bitmap bitmap, int downX, int downY) { mWindowLayoutParams = new WindowManager.LayoutParams(); mWindowLayoutParams.format = PixelFormat.TRANSLUCENT; // 图片之外的其他地方透明 mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowLayoutParams.x = downX - mPoint2ItemLeft + mOffset2Left; mWindowLayoutParams.y = downY - mPoint2ItemTop + mOffset2Top - mStatusHeight; mWindowLayoutParams.alpha = 0.55f; // 透明度 mWindowLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; mDragImageView = new ImageView(getContext()); mDragImageView.setImageBitmap(bitmap); mWindowManager.addView(mDragImageView, mWindowLayoutParams); }
public static Bitmap drawableToBitamp(Drawable drawable) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable); return bitmapDrawable.getBitmap(); } else { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; } }
@Opacity public static int getOpacityFromColor(int color) { int colorAlpha = color >>> 24; if (colorAlpha == 255) { return PixelFormat.OPAQUE; } else if (colorAlpha == 0) { return PixelFormat.TRANSPARENT; } else { return PixelFormat.TRANSLUCENT; } }
/** * 将Drawable转换为Bitmap * * @param drawable 要转换的Drawable * @return 转换后的Bitmap */ private Bitmap d2b(Drawable drawable) { if (null != drawable) { if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; } } return null; }
/** * A factory method to build the appropriate LuminanceSource object based on * the format of the preview buffers, as described by Camera.Parameters. * * @param data * A preview frame. * @param width * The width of the image. * @param height * The height of the image. * @return A PlanarYUVLuminanceSource instance. */ @SuppressWarnings("deprecation") public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { Rect rect = getFramingRectInPreview(); int previewFormat = configManager.getPreviewFormat(); String previewFormatString = configManager.getPreviewFormatString(); switch (previewFormat) { // This is the standard Android format which all devices are REQUIRED to // support. // In theory, it's the only one we should ever care about. case PixelFormat.YCbCr_420_SP: // This format has never been seen in the wild, but is compatible as // we only care // about the Y channel, so allow it. case PixelFormat.YCbCr_422_SP: return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height()); default: // The Samsung Moment incorrectly uses this variant instead of the // 'sp' version. // Fortunately, it too has all the Y data up front, so we can read // it. if ("yuv420p".equals(previewFormatString)) { return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height()); } } throw new IllegalArgumentException("Unsupported picture format: " + previewFormat + '/' + previewFormatString); }
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) return true; // View#isOpaque didn't take all valid opaque scrollbar modes into account // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false // here. On older devices, check the view's background drawable directly as a fallback. if (Build.VERSION.SDK_INT >= 18) return false; final Drawable bg = v.getBackground(); if (bg != null) { return bg.getOpacity() == PixelFormat.OPAQUE; } return false; }
public ImageSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); mSurHolder = getHolder(); mSurHolder.addCallback(this); this.setOnTouchListener(this); setZOrderOnTop(true);//使surfaceview放到最顶层 getHolder().setFormat(PixelFormat.TRANSLUCENT); }
@Override public void initialize(ApplicationListener listener, AndroidApplicationConfiguration config){ //Las siguientes dos lines son necesaria para poder añadir markers de la manera que ARToolKit lo maneja AssetHelper assetHelper = new AssetHelper(getAssets()); assetHelper.cacheAssetFolder(this, "Data"); mainLayout = new FrameLayout(this); config.r = 8; config.g = 8; config.b = 8; config.a = 8; //Configuraciones basicas requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setFormat(PixelFormat.TRANSLUCENT); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); gameView = initializeForView(listener, config); if(graphics.getView() instanceof SurfaceView){ SurfaceView glView = (SurfaceView)graphics.getView(); glView.getHolder().setFormat(PixelFormat.TRANSLUCENT); } setContentView(mainLayout); }
private WindowManager.LayoutParams createPopupLayout(IBinder token) { WindowManager.LayoutParams p = new WindowManager.LayoutParams(); p.gravity = Gravity.START | Gravity.TOP; p.width = ViewGroup.LayoutParams.MATCH_PARENT; p.height = ViewGroup.LayoutParams.MATCH_PARENT; p.format = PixelFormat.TRANSLUCENT; p.flags = computeFlags(p.flags); p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; p.token = token; p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN; p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode())); return p; }
@Test public void testGetOpacityFromColor() { assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00000000)); assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00123456)); assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00FFFFFF)); assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0000000)); assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0123456)); assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0FFFFFF)); assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFF000000)); assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFF123456)); assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFFFFFFFF)); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); L.e(getClass().getSimpleName() + " 任务栈:" + getTaskId()); getWindow().setFormat(PixelFormat.TRANSLUCENT);//TBS X5 loadActivityStyle(); initWindow(); initUIActivity(); // onCreateView(); }
@Override public void onCreate() { super.onCreate(); FrameLayout frameLayout = new FrameLayout(this); frameLayout.setBackgroundColor(getResources().getColor(R.color.colorPhoneDark, getTheme())); WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); //change this through preferences int dragWidth = 20; WindowManager.LayoutParams params = new WindowManager.LayoutParams(dragWidth, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); //change this through preferences params.gravity = Gravity.START; params.x = 0; params.y = 0; frameLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { Toast.makeText(OverlayService.this, "yo", Toast.LENGTH_SHORT) .show(); return false; } }); if (windowManager != null) { windowManager.addView(frameLayout, params); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_color_bar); mSurfaceView = (SurfaceView) findViewById(R.id.colorBarSurfaceView); mSurfaceView.getHolder().addCallback(this); mSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888); }
@Override public int getOpacity() { final int opacity; if (hasResult()) { opacity = result.getOpacity(); } else { opacity = PixelFormat.TRANSPARENT; } return opacity; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setUpVirtualDisplay() { mScreen = (ViewGroup) getActivity().getWindow().getDecorView().getRootView(); // display metrics DisplayMetrics metrics = getResources().getDisplayMetrics(); mDensity = metrics.densityDpi; Display mDisplay = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); mDisplay.getRealSize(size); mWidth = size.x; mHeight = size.y; // start capture reader mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2); int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null); size.set(mWidth, mHeight); //create ScreenCapturer mScreenCapturer = new ScreenSharingCapturer(getActivity(), mScreen, mImageReader); mListener.onScreenCapturerReady(); }
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); }