List of usage examples for android.graphics Color TRANSPARENT
int TRANSPARENT
To view the source code for android.graphics Color TRANSPARENT.
Click Source Link
From source file:Main.java
/** * Create a Bitmap that will be used as a mask to create the preview window in the background. * The Bitmap will be the given width and height. The Bitmap will be transparent except for a * gradient on the left and bottom sides. * * @param width Width of the mask./*ww w .j ava 2s.c o m*/ * @param height Height of the mask. * @param gradientSize Size of the gradient. * @return Bitmap mask that will be used to create a preview window. */ private static Bitmap createPreviewWindowMask(int width, int height, int gradientSize) { // Do nothing if the size is invalid if (width <= 0 || height <= 0) { return null; } // Initialize the mask Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); canvas.drawColor(Color.TRANSPARENT); // If the gradient size is zero, don't draw the gradients if (gradientSize <= 0) { return mask; } // Calculate gradient rects Rect leftGradientRect = new Rect(0, 0, gradientSize, height - gradientSize); Rect bottomGradientRect = new Rect(leftGradientRect.right, height - gradientSize, width, height); Rect cornerGradientRect = new Rect(leftGradientRect.left, leftGradientRect.bottom, bottomGradientRect.left, bottomGradientRect.bottom); // Create left gradient Paint leftGradientPaint = new Paint(); leftGradientPaint.setDither(true); leftGradientPaint.setShader(new LinearGradient(leftGradientRect.left, 0, leftGradientRect.right, 0, Color.BLACK, Color.TRANSPARENT, Shader.TileMode.CLAMP)); // Create right gradient Paint bottomGradientPaint = new Paint(); bottomGradientPaint.setDither(true); bottomGradientPaint.setShader( new LinearGradient(leftGradientRect.right, bottomGradientRect.bottom, leftGradientRect.right, bottomGradientRect.top, Color.BLACK, Color.TRANSPARENT, Shader.TileMode.CLAMP)); // Create corner gradient Paint cornerGradientPaint = new Paint(); cornerGradientPaint.setDither(true); cornerGradientPaint.setShader(new RadialGradient(cornerGradientRect.right, cornerGradientRect.top, gradientSize, Color.TRANSPARENT, Color.BLACK, Shader.TileMode.CLAMP)); // Draw the gradients canvas.drawRect(leftGradientRect, leftGradientPaint); canvas.drawRect(bottomGradientRect, bottomGradientPaint); canvas.drawRect(cornerGradientRect, cornerGradientPaint); return mask; }
From source file:Main.java
private static void setTransparentForWindow(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(Color.TRANSPARENT); activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }//from ww w . ja v a2 s. c o m }
From source file:com.spoiledmilk.ibikecph.navigation.FinishRouteDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); View view = inflater.inflate(R.layout.dialog_stop, container); textReport = (TextView) view.findViewById(R.id.textReport); textReport.setText(IbikeApplication.getString("ride_report_a_problem")); textReport.setTypeface(IbikeApplication.getBoldFont()); textReport.setOnClickListener(new OnClickListener() { @Override/* ww w . j ava 2s . c om*/ public void onClick(View arg0) { ((SMRouteNavigationActivity) getActivity()).launchReportIssuesActivity(); } }); textTitle = (TextView) view.findViewById(R.id.textTitle); textTitle.setText(IbikeApplication.getString("route_stop_title")); textTitle.setTypeface(IbikeApplication.getNormalFont()); btnBack = (Button) view.findViewById(R.id.btnBack); btnBack.setText(IbikeApplication.getString("back")); btnBack.setTypeface(IbikeApplication.getBoldFont()); btnBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getDialog().dismiss(); } }); btnStop = (TexturedButton) view.findViewById(R.id.btnStop); btnStop.setTextureResource(R.drawable.btn_pattern_repeteable); btnStop.setBackgroundResource(R.drawable.btn_blue_selector); btnStop.setText(IbikeApplication.getString("stop_ride")); btnStop.setTypeface(IbikeApplication.getBoldFont()); btnStop.setTextColor(Color.WHITE); btnStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getDialog().dismiss(); Bundle conData = new Bundle(); conData.putInt("overlaysShown", ((SMRouteNavigationActivity) getActivity()).getOverlaysShown()); Intent intent = new Intent(); intent.putExtras(conData); getActivity().setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION, intent); getActivity().finish(); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } }); return view; }
From source file:com.example.android.hcgallery.TitlesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //Current position should survive screen rotations. if (savedInstanceState != null) { mCategory = savedInstanceState.getInt("category"); mCurPosition = savedInstanceState.getInt("listPosition"); }//from www .j a va 2 s. c o m populateTitles(mCategory); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setCacheColorHint(Color.TRANSPARENT); selectPosition(mCurPosition); }
From source file:click.kobaken.rxirohaandroid_sample.view.fragment.SplashFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog();/*from w w w . ja v a 2 s .c om*/ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.fragment_splash); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); }
From source file:cn.bingoogolapple.refreshlayout.BGAWaveStyleRefreshViewHolder.java
@Override public View getRefreshHeaderView() { if (mRefreshHeaderView == null) { mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_mooc_style, null); mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT); if (mRefreshViewBackgroundColorRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes); }//from w ww .j a v a 2 s . c o m if (mRefreshViewBackgroundDrawableRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes); } mMoocRefreshView = (BGAWaveStyleRefreshView) mRefreshHeaderView.findViewById(R.id.moocView); if (mOriginalImageResId != -1) { mMoocRefreshView.setOriginalImage(mOriginalImageResId); } else { throw new RuntimeException("" + BGAWaveStyleRefreshViewHolder.class.getSimpleName() + "setOriginalImage?"); } if (mUltimateColorResId != -1) { mMoocRefreshView.setUltimateColor(mUltimateColorResId); } else { throw new RuntimeException("" + BGAWaveStyleRefreshViewHolder.class.getSimpleName() + "setUltimateColor??"); } } return mRefreshHeaderView; }
From source file:Main.java
/** * Load the image at {@code imagePath} as a {@link Bitmap}, scaling it to * the specified size and preserving the aspect ratio. * @param imagePath Path of the image to load. * @param width Required width of the resulting {@link Bitmap}. * @param height Required height of the resulting {@link Bitmap}. * @param fill {@code true} to fill the empty space with transparent color. * @param crop {@code true} to crop the image, {@code false} to resize without cutting the image. * @return {@link Bitmap} representing the image at {@code imagePath}. *//*from w w w . jav a2 s . c o m*/ public static Bitmap loadResizedBitmap(String imagePath, int width, int height, boolean fill, boolean crop) { Bitmap retVal; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inSampleSize = getScale(imagePath, width, height); opts.inJustDecodeBounds = false; Bitmap image = BitmapFactory.decodeFile(imagePath, opts); if (image == null) { return null; } if (image.getWidth() != width || image.getHeight() != height) { int scaledWidth = (image.getWidth() * height) / image.getHeight(); int scaledHeight; // = (image.getHeight() * width) / image.getWidth(); if ((crop && scaledWidth > width) || (!crop && scaledWidth < width)) { scaledHeight = height; } else { scaledWidth = width; scaledHeight = (image.getHeight() * width) / image.getWidth(); } //image = Bitmap.createScaledBitmap(image, scaledWidth, scaledHeight, true); Rect src = new Rect(0, 0, image.getWidth(), image.getHeight()); Rect dst = new Rect(0, 0, scaledWidth, scaledHeight); if (fill) { retVal = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); dst.offset((width - scaledWidth) / 2, (height - scaledHeight) / 2); } else { retVal = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888); } retVal.eraseColor(Color.TRANSPARENT); synchronized (canvas) { if (antiAliasPaint == null) { antiAliasPaint = new Paint(); antiAliasPaint.setAntiAlias(true); antiAliasPaint.setFilterBitmap(true); antiAliasPaint.setDither(true); } canvas.setBitmap(retVal); canvas.drawBitmap(image, src, dst, antiAliasPaint); } image.recycle(); } else { //No need to scale. retVal = image; } return retVal; }
From source file:cn.bingoogolapple.refreshlayout.BGAMoocStyleRefreshViewHolder.java
@Override public View getRefreshHeaderView() { if (mRefreshHeaderView == null) { mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_mooc_style, null); mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT); if (mRefreshViewBackgroundColorRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes); }/*from ww w . ja va 2 s. c o m*/ if (mRefreshViewBackgroundDrawableRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes); } mMoocRefreshView = (BGAMoocStyleRefreshView) mRefreshHeaderView.findViewById(R.id.moocView); if (mOriginalImageResId != -1) { mMoocRefreshView.setOriginalImage(mOriginalImageResId); } else { throw new RuntimeException("" + BGAMoocStyleRefreshViewHolder.class.getSimpleName() + "setOriginalImage?"); } if (mUltimateColorResId != -1) { mMoocRefreshView.setUltimateColor(mUltimateColorResId); } else { throw new RuntimeException("" + BGAMoocStyleRefreshViewHolder.class.getSimpleName() + "setUltimateColor??"); } } return mRefreshHeaderView; }
From source file:com.facebook.react.views.view.ReactViewBackgroundManager.java
public void setBackgroundColor(int color) { if (color == Color.TRANSPARENT && mReactBackgroundDrawable == null) { // don't do anything, no need to allocate ReactBackgroundDrawable for transparent background } else {// w ww . j ava 2 s . c o m getOrCreateReactViewBackground().setColor(color); } }
From source file:com.liujs.library.view.refresh.BGAMoocStyleRefreshViewHolder.java
@Override public View getRefreshHeaderView() { if (mRefreshHeaderView == null) { mRefreshHeaderView = View.inflate(mContext, com.liujs.library.R.layout.view_refresh_header_mooc_style, null);/*from ww w . j a va2 s .co m*/ mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT); if (mRefreshViewBackgroundColorRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes); } if (mRefreshViewBackgroundDrawableRes != -1) { mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes); } mMoocRefreshView = (BGAMoocStyleRefreshView) mRefreshHeaderView .findViewById(com.liujs.library.R.id.moocView); if (mOriginalImageResId != -1) { mMoocRefreshView.setOriginalImage(mOriginalImageResId); } else { throw new RuntimeException("" + BGAMoocStyleRefreshViewHolder.class.getSimpleName() + "setOriginalImage?"); } if (mUltimateColorResId != -1) { mMoocRefreshView.setUltimateColor(mUltimateColorResId); } else { throw new RuntimeException("" + BGAMoocStyleRefreshViewHolder.class.getSimpleName() + "setUltimateColor??"); } } return mRefreshHeaderView; }