Example usage for android.graphics PixelFormat TRANSLUCENT

List of usage examples for android.graphics PixelFormat TRANSLUCENT

Introduction

In this page you can find the example usage for android.graphics PixelFormat TRANSLUCENT.

Prototype

int TRANSLUCENT

To view the source code for android.graphics PixelFormat TRANSLUCENT.

Click Source Link

Document

System chooses a format that supports translucency (many alpha bits)

Usage

From source file:Main.java

/**
 * Play video file from res folder.//w  ww .  j  av a 2  s .c om
 * Then call video.start();
 * @param activity - current Activity
 * @param videoViewId R.id.introVideo
 * @param videoResourceId R.raw.intro - res/raw/intro.mp4
 * @return VideoView
 */
public static VideoView playVideo(Activity activity, int videoViewId, int videoResourceId,
        MediaPlayer.OnCompletionListener listener) {
    activity.getWindow().setFormat(PixelFormat.TRANSLUCENT);
    VideoView view = (VideoView) activity.findViewById(videoViewId);
    view.setVideoURI(
            Uri.parse("android.resource://" + activity.getPackageName() + File.separator + videoResourceId));
    view.setKeepScreenOn(true);
    view.setMediaController(null);
    view.setOnCompletionListener(listener);
    view.requestFocus();
    return view;
}

From source file:Main.java

/**
 * Gets the opacity from a color. Inspired by Android ColorDrawable.
 * @param color/*from  w ww  .  j  av  a2s . c om*/
 * @return opacity expressed by one of PixelFormat constants
 */
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;
    }
}

From source file:com.example.android.opengl.OpenGLES20Activity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create a GLSurfaceView instance and set it
    // as the ContentView for this Activity
    mGLView = new MyGLSurfaceView(this);
    mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(mGLView);//w  ww .ja v a2s. c  o  m
    ViewCompat.postOnAnimation(mGLView, new Runnable() {
        public void run() {
            mGLView.requestRender();
            ViewCompat.postOnAnimation(mGLView, this);
        }
    });
    setFullScreen(true);
}

From source file:co.adrianblan.fastbrush.MyGLSurfaceView.java

public MyGLSurfaceView(Context context) {
    super(context);

    // Create an OpenGL ES 3.0 context.
    setEGLContextClientVersion(3);/*from   ww  w  .  ja  va 2 s.  c  o m*/

    // Sets a paper background to the scene
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    getHolder().setFormat(PixelFormat.TRANSLUCENT);
    setBackgroundResource(R.drawable.paperbright);
    setZOrderOnTop(true);

    // Set the Renderer for drawing on the GLSurfaceView
    mRenderer = new MyGLRenderer(context);
    setRenderer(mRenderer);

    // Render the view only when there is a change in the drawing data
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    setPreserveEGLContextOnPause(true);
}

From source file:io.github.importre.android.chromeadb.ChromeAdbService.java

private void addMouseCursor() {
    if (mCursorImage == null) {
        mCursorImage = new ImageView(this);
        mCursorImage.setImageResource(R.drawable.cursor);
    }/*from w ww. java2s.  c  o m*/

    if (mLayoutParam == null) {
        mLayoutParam = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        mLayoutParam.gravity = Gravity.LEFT | Gravity.TOP;
        mLayoutParam.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    }

    if (mWindowManager == null) {
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mWindowManager.addView(mCursorImage, mLayoutParam);
    }
}

From source file:com.pyamsoft.zaptorch.service.OriginalCamera.java

OriginalCamera(final @NonNull Context context, final @NonNull VolumeServiceInteractor interactor) {
    super(context, interactor);
    Timber.d("OLD CAMERA API");
    opened = false;/*from www .  j a  v  a 2s.  com*/

    surfaceView = new SurfaceView(getAppContext());
    windowManager = (WindowManager) getAppContext().getSystemService(Context.WINDOW_SERVICE);

    params = new WindowManager.LayoutParams();
    params.width = 1;
    params.height = 1;
    params.gravity = Gravity.TOP | Gravity.START;
    params.format = PixelFormat.TRANSLUCENT;
    params.type = WindowManager.LayoutParams.TYPE_TOAST;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
}

From source file:com.king.android.common.widget.badge.BGADragBadgeView.java

private void initLayoutParams() {
    mLayoutParams = new WindowManager.LayoutParams();
    mLayoutParams.gravity = Gravity.LEFT + Gravity.TOP;
    mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
    mLayoutParams.format = PixelFormat.TRANSLUCENT;
    mLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    mLayoutParams.width = mWindowManager.getDefaultDisplay().getWidth();
    mLayoutParams.height = mWindowManager.getDefaultDisplay().getHeight();
}

From source file:android.support.v17.leanback.app.ErrorSupportFragment.java

/**
 * Sets a drawable for the fragment background.
 *
 * @param drawable The drawable used for the background.
 *//*from   w w  w  .j a v a  2 s.  c o  m*/
public void setBackgroundDrawable(Drawable drawable) {
    mBackgroundDrawable = drawable;
    if (drawable != null) {
        final int opacity = drawable.getOpacity();
        mIsBackgroundTranslucent = (opacity == PixelFormat.TRANSLUCENT || opacity == PixelFormat.TRANSPARENT);
    }
    updateBackground();
    updateMessage();
}

From source file:com.smart.able2include.SimpleTextOverlayView.java

private void createView() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;/*from  ww  w.  j  ava 2 s .  c o  m*/
    params.y = 30;
    params.width = wm.getDefaultDisplay().getWidth();
    params.height = wm.getDefaultDisplay().getHeight() - 30;

    frameLayout = new RelativeLayout(mServiceContext);
    LayoutInflater layoutInflater = (LayoutInflater) mServiceContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout);

    TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText);
    text.setText(mSimpleText);
    dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            RemoveOvelay();
            delegate.onClick();
        }
    });
    synchronized (mSyncToken) {
        wm.addView(frameLayout, params);
        mOnTop = true;
    }
}

From source file:com.github.shareme.gwscleanstatusbar.CleanStatusBarService.java

private WindowManager.LayoutParams getWindowManagerParams() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT); // must be translucent to support KitKat gradient
    params.gravity = Gravity.TOP;//from   w  w w. j  a  v  a  2s .co  m
    params.height = mStatusBarConfig.getStatusBarHeight();
    return params;
}