Example usage for android.graphics Color argb

List of usage examples for android.graphics Color argb

Introduction

In this page you can find the example usage for android.graphics Color argb.

Prototype

@ColorInt
public static int argb(float alpha, float red, float green, float blue) 

Source Link

Document

Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).

Usage

From source file:com.cburch.logisim.gui.start.AboutCredits.java

private int derive(int baseColor, int alpha) {
    return Color.argb(alpha, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
}

From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java

private int getColor(int normalColor, int selectedColor, float offset) {
    int normalAlpha = Color.alpha(normalColor);
    int normalRed = Color.red(normalColor);
    int normalGreen = Color.green(normalColor);
    int normalBlue = Color.blue(normalColor);
    int selectedAlpha = Color.alpha(selectedColor);
    int selectedRed = Color.red(selectedColor);
    int selectedGreen = Color.green(selectedColor);
    int selectedBlue = Color.blue(selectedColor);
    int a = (int) Math.ceil((selectedAlpha - normalAlpha) * offset);
    int r = (int) Math.ceil((selectedRed - normalRed) * offset);
    int g = (int) Math.ceil((selectedGreen - normalGreen) * offset);
    int b = (int) Math.ceil((selectedBlue - normalBlue) * offset);
    return Color.argb(normalAlpha + a, normalRed + r, normalGreen + g, normalBlue + b);
}

From source file:edu.rowan.app.carousel.CarouselFeature.java

private void setupView() {
    imageView.setId(1);/*from   ww  w .  j  a  v  a 2 s  . co  m*/
    RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
    imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    imageView.setLayoutParams(imageParams);
    //      imageView.setAdjustViewBounds(true);
    Resources r = context.getResources();
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics());

    TextView descriptionView = new TextView(context);
    descriptionView.setId(2);
    descriptionView.setPadding(padding, 0, padding, padding);
    descriptionView.setText(description);
    descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10));
    descriptionView.setTextColor(Color.WHITE);
    RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId());
    carouselView.addView(descriptionView, descParams);

    TextView titleView = new TextView(context);
    titleView.setText(title);
    titleView.setPadding(padding, 0, padding, 0);
    RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId());
    titleView.setLayoutParams(titleParams);
    titleView.setTextColor(Color.WHITE);
    titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0));
    titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);

    carouselView.addView(titleView);
}

From source file:com.cyrilmottier.android.polaris2demo.PolygonDemoActivity.java

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (mMutablePolygon == null) {
        return;// www .j  a v a 2 s .  c o  m
    }

    if (seekBar == mColorBar) {
        mMutablePolygon.setFillColor(
                Color.HSVToColor(Color.alpha(mMutablePolygon.getFillColor()), new float[] { progress, 1, 1 }));
    } else if (seekBar == mAlphaBar) {
        int prevColor = mMutablePolygon.getFillColor();
        mMutablePolygon.setFillColor(
                Color.argb(progress, Color.red(prevColor), Color.green(prevColor), Color.blue(prevColor)));
    } else if (seekBar == mWidthBar) {
        mMutablePolygon.setStrokeWidth(progress);
    }
}

From source file:com.mci.firstidol.view.ActionSheet.java

@SuppressWarnings("deprecation")
private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/*ww w .j  a va  2 s. c  om*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);

    TextView titleView = new TextView(getActivity());
    titleView.setText(TextUtils.isEmpty(getTitle()) ? "" : getTitle());
    titleView.setGravity(Gravity.CENTER);
    titleView.setTextColor(Color.GRAY);
    titleView.setBackgroundDrawable(mAttrs.actionSheetTitleBackground);
    mPanel.addView(titleView);

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.fizz.StickyFragment.java

@Override
public void onStart() {
    super.onStart();
    LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.ll);
    for (int i = 0; i < drinks.length; i++) {
        TextView tt = new TextView(getActivity());
        tt.setText(drinks[i].toUpperCase(Locale.US) + "\n" + ingredients[i]);
        tt.setPadding(15, 15, 15, 15);/* w w  w .ja v a2  s.c  om*/
        tt.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drink = ((TextView) v).getText().toString();
                try {
                    Intent venmoIntent = VenmoLibrary.openVenmoPayment("1684", "Fizz", "8123744601", "0.01",
                            drink, "pay");
                    startActivityForResult(venmoIntent, 1);
                    // 1 is the requestCode we are using for Venmo. Feel
                    // free to change this to another number.

                    // Venmo native app not install on device, so let's
                    // instead open a mobile web version of Venmo in a
                    // WebView
                } catch (android.content.ActivityNotFoundException e) {
                    Log.e("Fizz", "onClicked");
                    {
                        Intent venmoIntent = new Intent(getActivity(), VenmoWebViewActivity.class);
                        String venmo_uri = VenmoLibrary.openVenmoPaymentInWebView("1684", "Fizz", "8123744601",
                                "0.01", "Drink", "pay");
                        venmoIntent.putExtra("url", venmo_uri);
                        startActivityForResult(venmoIntent, 1);
                    }
                    //} catch (android.content.ActivityNotFoundException e) {
                    //e.printStackTrace() ;
                }
            }
        });
        tt.setTextSize(22);
        if (textnum % 2 == 0) {
            tt.setBackgroundColor(Color.argb(0, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 51, 181, 229));
        } else {
            tt.setBackgroundColor(Color.argb(240, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 255, 255, 255));
        }
        tt.setTypeface(SplashActivity.tp);
        ll.addView(tt);
        textnum++;
    }
}

From source file:com.base.view.slidemenu.SlideMenu.java

public SlideMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // we want to draw drop shadow of content
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mVelocityTracker = VelocityTracker.obtain();
    mContentHitRect = new Rect();
    mEdgeSlideDetectRect = new Rect();
    STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context);
    setWillNotDraw(false);/*from   w  ww  .j  av a  2s. c  o  m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0);

    // Set the shadow attributes
    setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30));
    setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30));

    Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable);
    if (null == primaryShadowDrawable) {
        primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) });
    }
    setPrimaryShadowDrawable(primaryShadowDrawable);

    Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_secondaryShadowDrawable);
    if (null == secondaryShadowDrawable) {
        secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT });
    }
    setSecondaryShadowDrawable(secondaryShadowDrawable);

    int interpolatorResId = a.getResourceId(R.styleable.SlideMenu_interpolator, -1);
    setInterpolator(-1 == interpolatorResId ? DEFAULT_INTERPOLATOR
            : AnimationUtils.loadInterpolator(context, interpolatorResId));

    mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection,
            FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT);

    setEdgeSlideEnable(a.getBoolean(R.styleable.SlideMenu_edgeSlide, false));
    setEdgetSlideWidth(a.getDimensionPixelSize(R.styleable.SlideMenu_edgeSlideWidth, 100));
    a.recycle();

    setFocusable(true);
    setFocusableInTouchMode(true);
}

From source file:com.antonioleiva.materializeyourapp.DetailActivity.java

private int getAlphaColor(int color, float scrollRatio) {
    return Color.argb((int) (scrollRatio * 255f), Color.red(color), Color.green(color), Color.blue(color));
}

From source file:com.grepsound.activities.MainActivity.java

private void setupNavigationDrawer(boolean locked) {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            mToolbar, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */) {

        public ColorDrawable toolbarDrawable;
        public int toolbarColor = getResources().getColor(R.color.holo_orange_light);

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
            Log.i(TAG, "CLOSED");
        }//from w  ww . j  av  a 2  s.c  o m

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            int ratioRed = Math.round(Color.red(toolbarColor) - Color.red(toolbarColor) * slideOffset);
            int ratioGreen = Math.round(Color.green(toolbarColor) - Color.green(toolbarColor) * slideOffset);
            int ratioBlue = Math.round(Color.blue(toolbarColor) - Color.blue(toolbarColor) * slideOffset);

            toolbarDrawable = new ColorDrawable(Math.round(0xFFFFFFFF * slideOffset));
            toolbarDrawable.setColor(Color.argb(255, ratioRed, ratioGreen, ratioBlue));

            getSupportActionBar().setBackgroundDrawable(toolbarDrawable);
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu(); // creates call to
            Log.i(TAG, "OPEN");
            // onPrepareOptionsMenu()
        }

    };

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "GOOD");
            if (getFragmentManager().getBackStackEntryCount() > 0)
                getFragmentManager().popBackStack();
            else {
                if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
                    mDrawerLayout.closeDrawer(GravityCompat.START);
                else
                    mDrawerLayout.openDrawer(GravityCompat.START);
            }
        }
    });

    if (locked) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
    } else {
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    }

    mDrawerToggle.setDrawerIndicatorEnabled(!locked);
    getSupportActionBar().setHomeButtonEnabled(!locked);
}

From source file:com.example.mego.adas.accidents.ui.AccidentDetailFragment.java

/**
 * Method to set current accident to the map
 */// w  w w.j  a v a2s  .c  o m
private void setCurrentAccidentToMap() {
    if (mapReady && accidentLatitude != 0 && accidentLongitude != 0) {

        carPlace = new MarkerOptions().position(new LatLng(accidentLatitude, accidentLongitude))
                .title("Accident Place").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker));

        accidentPlace = new LatLng(accidentLatitude, accidentLongitude);

        cameraPosition = CameraPosition.builder().target(new LatLng(accidentLatitude, accidentLongitude))
                .zoom(zoom).bearing(bearing).tilt(tilt).build();

        mMap.addCircle(new CircleOptions().center(accidentPlace).radius(50)
                .strokeColor(getResources().getColor(R.color.red)).fillColor(Color.argb(64, 255, 0, 0)));

        mMap.addMarker(carPlace);
        flyTo(cameraPosition);
    }
}