List of usage examples for android.view SurfaceHolder setFormat
public void setFormat(int format);
From source file:com.intel.xdk.display.Display.java
@JavascriptInterface public void startAR() { arView = CameraPreview.newInstance(activity.getApplicationContext()); arView.setVisibility(View.INVISIBLE); arView.height = 100;/*from w w w . j a v a 2 s. c om*/ arView.width = 100; //no way to get current background color? arView.setBackgroundColor(Color.TRANSPARENT); SurfaceHolder sfhTrackHolder = arView.getHolder(); sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT); sfhTrackHolder.setKeepScreenOn(true); sfhTrackHolder.setFixedSize(100, 100); activity.runOnUiThread(new Runnable() { public void run() { //activity.addContentView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F)); //activity.addContentView(arView, new LinearLayout.LayoutParams(400, 500, 0.0F)); ViewGroup rootView = (ViewGroup) webView.getParent().getParent(); rootView.addView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); rootView.bringChildToFront((View) webView.getParent()); arView.setVisibility(View.VISIBLE); arView.showCamera(); webView.bringToFront(); webView.setBackgroundColor(0x00000000); LinearLayout ll = (LinearLayout) webView.getParent(); ll.setBackgroundColor(0x00000000); View activityView = activity.getCurrentFocus(); } }); }
From source file:com.android.screenspeak.contextmenu.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;//w ww. ja v a 2s . c o m mRootMenu.setLayoutListener(new RadialMenu.MenuLayoutListener() { @Override public void onLayoutChanged() { invalidate(); } }); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(new LongPressHandler.LongPressListener() { @Override public void onLongPress() { onItemLongPressed(mFocusedItem); } }); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { mHolder = holder; } @Override public void surfaceDestroyed(SurfaceHolder holder) { mHolder = null; } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { invalidate(); } }); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { // Lazily-constructed node provider helper. ViewCompat.setAccessibilityDelegate(this, new RadialMenuHelper(this)); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }
From source file:com.googlecode.eyesfree.widget.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;/*from www . j a v a 2 s .co m*/ mRootMenu.setLayoutListener(mLayoutListener); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(mLongPressListener); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(mSurfaceCallback); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { mTouchExplorer = new RadialMenuHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchExplorer); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }