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.amaze.carbonfilemanager.ui.views.Indicator.java

public Indicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Indicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.Indicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;/*from w w  w .  j  a  va2s.c  o m*/
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.Indicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.Indicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    selectedColour = a.getColor(R.styleable.Indicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR);
    // half transparent accent color
    unselectedColour = Color.argb(80, Color.red(selectedColour), Color.green(selectedColour),
            Color.blue(selectedColour));

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:io.rapidpro.androidchannel.HomeActivity.java

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

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.home);/*from w  w  w  .  j a v a  2s. c  o  m*/

    m_lastUpdated = findViewById(R.id.last_updated);
    m_lastUpdate = findViewById(R.id.last_update);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());

    Boolean showAdvancedSettings = prefs.getBoolean(SHOW_ADVANCED_SETTINGS, false);

    if (!showAdvancedSettings) {
        m_logo = findViewById(R.id.logo);

        m_logo.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                int action = MotionEventCompat.getActionMasked(motionEvent);

                switch (action) {
                case (MotionEvent.ACTION_DOWN):
                    long now = System.currentTimeMillis();
                    if (now - m_lastTouch < 2000) {
                        if (m_debugTapsRemaining >= 1) {
                            m_debugTapsRemaining--;
                        } else {
                            SharedPreferences.Editor editor = PreferenceManager
                                    .getDefaultSharedPreferences(getApplicationContext()).edit();
                            editor.putBoolean(SHOW_ADVANCED_SETTINGS, true);
                            editor.commit();
                            Toast.makeText(getApplicationContext(), "Advanced Settings Activated",
                                    Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        // reset m_touch_count to 8 to force exactly 10 touch from the user
                        m_debugTapsRemaining = 8;
                    }
                    m_lastTouch = now;

                    return false;

                default:
                    return false;
                }
            }
        });
    }

    m_settings = findViewById(R.id.settings_icon);
    m_settings.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            int action = MotionEventCompat.getActionMasked(motionEvent);

            switch (action) {
            case (MotionEvent.ACTION_DOWN):
                m_settings.setBackgroundColor(Color.argb(32, 255, 255, 255));
                return false;
            case (MotionEvent.ACTION_UP):
                m_settings.setBackgroundColor(Color.TRANSPARENT);
                return false;
            default:
                return false;

            }

        }
    });

    m_status = (TextView) findViewById(R.id.status);
    m_statusBar = (LinearLayout) findViewById(R.id.status_bar);

    s_this = this;

    m_outgoingCount = (TextView) findViewById(R.id.outgoing_count);
    m_retryCount = (TextView) findViewById(R.id.retry_count);
    m_syncCount = (TextView) findViewById(R.id.sync_count);

    // initialize our dashboard
    updateClaimCode(this);
}

From source file:com.example.piechartandlist.MainActivity.java

private void initialPieChart() {
    ChartFragment pieChartFragment = (ChartFragment) getFragmentManager().findFragmentById(R.id.pie_chart);

    // Get the a reference to the ShinobiChart from the ChartFragment
    ShinobiChart shinobiChart = pieChartFragment.getShinobiChart();

    // Set trial license key
    shinobiChart.setLicenseKey(/*from  w  w w. j a v a  2  s .  co m*/
            "UONigH/ewqTlGfoMjAxNTAzMjh3dXdlaTExMDdAZ21haWwuY29tcmOO/9ehRYw49tpfd+k4Wz/vGSVoFNI7J8QXZe2ajp+Q0tQ4WEdAa69XC9uwCtr1+avEWUouirJs8fOBMv3Zc2HKnkWsZqpD3hQ0G3Vykk2akXjEOHycCSUmh98aRhtMifqSPx6HRsDPFMwDggeHIZH9w97w=BQxSUisl3BaWf/7myRmmlIjRnMU2cA7q+/03ZX9wdj30RzapYANf51ee3Pi8m2rVW6aD7t6Hi4Qy5vv9xpaQYXF5T7XzsafhzS3hbBokp36BoJZg8IrceBj742nQajYyV7trx5GIw9jy/V6r0bvctKYwTim7Kzq+YPWGMtqtQoU=PFJTQUtleVZhbHVlPjxNb2R1bHVzPnh6YlRrc2dYWWJvQUh5VGR6dkNzQXUrUVAxQnM5b2VrZUxxZVdacnRFbUx3OHZlWStBK3pteXg4NGpJbFkzT2hGdlNYbHZDSjlKVGZQTTF4S2ZweWZBVXBGeXgxRnVBMThOcDNETUxXR1JJbTJ6WXA3a1YyMEdYZGU3RnJyTHZjdGhIbW1BZ21PTTdwMFBsNWlSKzNVMDg5M1N4b2hCZlJ5RHdEeE9vdDNlMD08L01vZHVsdXM+PEV4cG9uZW50PkFRQUI8L0V4cG9uZW50PjwvUlNBS2V5VmFsdWU+");

    // Create our DataAdapter and data
    dataAdapter = new SimpleDataAdapter<String, Double>();

    // Create a PieSeries and give it the data adapter
    series = new PieSeries();
    series.setSelectionMode(Series.SelectionMode.POINT_SINGLE);
    // The value represents the angle in radians in an anti-clockwise direction
    series.setSelectedPosition(50.0f);
    series.setDataAdapter(dataAdapter);
    shinobiChart.addSeries(series);

    // Apply styling to the Pie Series
    PieSeriesStyle style = series.getStyle();
    style.setFlavorColors(new int[] { Color.argb(255, 103, 169, 66), // green
            Color.argb(255, 248, 184, 60), // yellow
            Color.argb(255, 255, 51, 51) // red
    });
    style.setRadialEffect(PieDonutSeries.RadialEffect.DEFAULT);
    style.setCrustShown(false);
    style.setLabelTextSize(16.0f);

    // apply style to selected slices
    PieSeriesStyle selectedSeriesStyle = series.getSelectedStyle();
    selectedSeriesStyle.setFlavorColors(new int[] { Color.argb(255, 103, 169, 66), // green
            Color.argb(255, 248, 184, 60), // yellow
            Color.argb(255, 255, 51, 51) // red
    });
    selectedSeriesStyle.setCrustThickness(10f);
    selectedSeriesStyle.setCrustColors(new int[] { Color.argb(255, 0, 0, 0), // black
    });
    series.setSelectedStyle(selectedSeriesStyle);
}

From source file:com.aretha.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();
    mScroller = new Scroller(context, mInterpolator);
    mContentHitRect = new Rect();
    STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context);
    setWillNotDraw(false);//  ww w .  j a va 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_primaryShadowDrawable);
    if (null == secondaryShadowDrawable) {
        secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT });
    }
    setSecondaryShadowDrawable(secondaryShadowDrawable);

    mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection,
            FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT);
    setFocusable(true);
    setFocusableInTouchMode(true);
    a.recycle();
}

From source file:com.fancy.path_anim_lib.AnimatedSvgView.java

/**
 * /*w w  w . j a v a  2  s  . co m*/
 *
 */
public void setTraceResidueColors(int alpha, int red, int green, int blue) {
    int traceResidueColor = Color.argb(alpha, red, green, blue);
    int[] traceResidueColors = new int[2]; // 4 glyphs
    for (int i = 0; i < traceResidueColors.length; i++) {
        traceResidueColors[i] = traceResidueColor;
    }
    mTraceResidueColors = traceResidueColors;
}

From source file:com.sckftr.android.app.view.InsetFrameLayout.java

public void setAnimationProgress(float progress) {
    this.mAnimationProgress = progress;

    float fraction = progress / (float) mAnimationDuration;

    setInsetBackgroundColor(Color.argb(evaluate(fraction, Color.alpha(mStartColor), Color.alpha(mEndColor)), //alpha
            evaluate(fraction, Color.red(mStartColor), Color.red(mEndColor)), // red
            evaluate(fraction, Color.green(mStartColor), Color.green(mEndColor)), // green
            evaluate(fraction, Color.blue(mStartColor), Color.blue(mEndColor)))); // blue
}

From source file:es.rczone.tutoriales.gmaps.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_legalnotices:
        showLegalNotice();//  w ww. j  ava2s .c o  m
        break;

    case R.id.menu_view_type:
        changeTypeView();
        break;

    case R.id.menu_3d_animation:
        animation3DExample();
        break;

    case R.id.menu_camera_position:
        showCameraPosition();
        //this.pos_actual = map.getMyLocation();
        break;

    case R.id.Madrid_Barcelona:
        routeFromMadridToBarcelona();
        break;

    case R.id.enter_address:
        enterAddress();

    case R.id.kml_madrid:
        kmlOfMadrid();
        break;

    case R.id.menu_borrar_polylineas:
        borrarPolylineas();
        break;

    case R.id.menu_mostrar_radio:

        if (currentLocation == null) {
            Toast.makeText(this, "Primero debes consultar tu posicin", Toast.LENGTH_SHORT).show();
            super.onOptionsItemSelected(item);
        }

        if (circulo_radio == null) {
            LatLng pos = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
            CircleOptions circleOptions = new CircleOptions();
            circleOptions.center(pos);
            circleOptions.radius(500); // In meters
            circleOptions.strokeColor(Color.BLUE);
            circleOptions.fillColor(Color.argb(100, 0, 0, 255));

            circulo_radio = map.addCircle(circleOptions);
        } else {
            LatLng pos = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
            circulo_radio.setCenter(pos);
            circulo_radio.setRadius(200);
        }
        break;

    }

    return super.onOptionsItemSelected(item);
}

From source file:dimchoi.com.my.widget.AnimatedSvgView.java

private void init(Context context, AttributeSet attrs) {
    mFillPaint = new Paint();
    mFillPaint.setAntiAlias(true);/*www  .  j a va 2  s  . c  om*/
    mFillPaint.setStyle(Paint.Style.FILL);

    mTraceColors = new int[1];
    mTraceColors[0] = Color.BLACK;
    mTraceResidueColors = new int[1];
    mTraceResidueColors[0] = 0x32000000;

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView);
        mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeX, 512);
        aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeX, 512);
        mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeY, 512);
        aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeY, 512);
        mTraceTime = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceTime, 2000);
        mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceTimePerGlyph, 1000);
        mFillStart = a.getInt(R.styleable.AnimatedSvgView_animatedSvgFillStart, 1200);
        mFillTime = a.getInt(R.styleable.AnimatedSvgView_animatedSvgFillTime, 1000);
        int traceMarkerLength = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceMarkerLength, 16);
        mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, traceMarkerLength,
                getResources().getDisplayMetrics());
        int glyphStringsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgGlyphStrings, 0);
        int traceResidueColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgTraceResidueColors,
                0);
        int traceColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgTraceColors, 0);
        int fillColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgFillColors, 0);

        a.recycle();

        if (glyphStringsId != 0) {
            setGlyphStrings(getResources().getStringArray(glyphStringsId));
            setTraceResidueColor(Color.argb(50, 0, 0, 0));
            setTraceColor(Color.BLACK);
        }
        if (traceResidueColorsId != 0) {
            setTraceResidueColors(getResources().getIntArray(traceResidueColorsId));
        }
        if (traceColorsId != 0) {
            setTraceColors(getResources().getIntArray(traceColorsId));
        }
        if (fillColorsId != 0) {
            setFillColors(getResources().getIntArray(fillColorsId));
        }

        mViewport = new PointF(mViewportWidth, mViewportHeight);
    }

    // Note: using a software layer here is an optimization. This view works with hardware accelerated rendering but
    // every time a path is modified (when the dash path effect is modified), the graphics pipeline will rasterize
    // the path again in a new texture. Since we are dealing with dozens of paths, it is much more efficient to
    // rasterize the entire view into a single re-usable texture instead. Ideally this should be toggled using a
    // heuristic based on the number and or dimensions of paths to render.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}

From source file:com.urbantamil.projmadurai.MaduraiBookCoverFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootV = inflater.inflate(R.layout.fragment_madurai_book_cover, container, false);
    View floatbar = (View) rootV.findViewById(R.id.projmad_bookcover_floatbar_top);
    short[] rgba = colors_rgba[Integer.valueOf(mColorCode)];
    int bgcolor = Color.argb(rgba[3], rgba[0], rgba[1], rgba[2]);
    floatbar.setBackgroundColor(bgcolor);

    TextView toptext = (TextView) rootV.findViewById(R.id.projmad_bookcover_toptext);
    toptext.setText(mTopText);//from w w  w.j a va 2 s.com

    TextView author = (TextView) rootV.findViewById(R.id.projmad_bookcover_author_name);
    author.setText(mAuthor);

    TextView title = (TextView) rootV.findViewById(R.id.projmad_bookcover_title);
    title.setText(mTitle);

    TextView guide = (TextView) rootV.findViewById(R.id.projmad_bookcover_guide_text);
    guide.setText(mGuideText);

    ImageView animal = (ImageView) rootV.findViewById(R.id.projmad_bookcover_animal_image);
    animal.setImageResource(animal_ids[Integer.valueOf(mAnimalCode)]);

    rootV.setBackgroundColor(bgcolor ^ 0x00FFFFFF);
    return rootV;
}

From source file:com.itraing.views.ActionSheet.java

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);//from w  w w  .j av a2 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);

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