Example usage for android.graphics Color rgb

List of usage examples for android.graphics Color rgb

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:au.com.zacher.popularmovies.activity.layout.CollapsingTitleLayout.java

public void setTextAppearance(int resId) {
    TypedArray atp = this.getContext().obtainStyledAttributes(resId, R.styleable.CollapsingTextAppearance);
    this.mTextPaint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE));
    this.mCollapsedTitleTextSize = atp
            .getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, 0);

    // added shadow so the text shows better on top of bright images
    this.mTextPaint.setShadowLayer(5, 0, 0, Color.rgb(0, 0, 0));

    atp.recycle();//from w ww  .  j  a  v  a  2  s  .com

    this.recalculate();
}

From source file:org.lytsing.android.weibo.ui.StatusDetailActivity.java

private void initView() {

    mCommentsAdapter = new CommentsAdapter(this);
    mListView = (ListView) findViewById(R.id.list_view);

    View view = Util.inflateView(R.layout.list_item_stream_activity, this, null);

    mAdapter = new MergeAdapter();
    mAdapter.addView(view);/*w  w w  .  j  a  va  2s.c om*/
    mAdapter.addAdapter(mCommentsAdapter);
    mListView.setAdapter(mAdapter);

    aq = new AQuery(view);

    aq.id(R.id.stream_user_name).text(mStatus.user.name);
    aq.id(R.id.stream_content).text(mStatus.text).visible();

    ((NetworkImageView) view.findViewById(R.id.stream_user_image)).setImageUrl(mStatus.user.profile_image_url,
            getWeiboApplication().getImageLoader());

    if (mStatus.bmiddle_pic != null) {
        NetworkImageView bmiddlePic = ((NetworkImageView) view.findViewById(R.id.stream_media_1_1));
        bmiddlePic.setVisibility(View.VISIBLE);
        bmiddlePic.setImageUrl(mStatus.bmiddle_pic, getWeiboApplication().getImageLoader());
    }

    if (mStatus.retweeted_status != null) {
        aq.id(R.id.stream_reshare_line).visible();
        String retweetedText = "";
        if (mStatus.retweeted_status.user != null) {
            retweetedText = "@" + mStatus.retweeted_status.user.name + ":";
        }
        retweetedText += mStatus.retweeted_status.text;
        aq.id(R.id.stream_detail_text).text(retweetedText).textColor(Color.rgb(51, 181, 229)).visible();
    }

    if (mStatus.reposts_count > 0) {
        aq.id(R.id.tweet_redirect_pic).visible();
        aq.id(R.id.tweet_redirect).text(String.valueOf(mStatus.reposts_count)).visible();
    }

    if (mStatus.geo != null) {
        aq.id(R.id.maps_layout).visible();
        NetworkImageView mapView = (NetworkImageView) view.findViewById(R.id.pic_preview_iv);
        mapView.setImageUrl(getGeoGoogleMapUrl(), getWeiboApplication().getImageLoader());
    }

    if (mStatus.comments_count > 0) {
        aq.id(R.id.tweet_comment_pic).visible();
        aq.id(R.id.tweet_comment).text(String.valueOf(mStatus.comments_count)).visible();
        loadCommentData();
    } else {
        mCommentsAdapter.refresh();
    }

    aq = new AQuery(this);
    aq.id(R.id.send_button_comment).clicked(this, "buttonClickedQuickPost");
}

From source file:com.leeon.blank.widget.RangeBarNew.java

private void applyConfig(Context context, AttributeSet attrs) {
    if (attrs == null) {
        return;//from ww w .  j  a  va  2 s .com
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RangeBar);
    indicatorDrawable = a.getDrawable(R.styleable.RangeBar_indicatorDrawable);
    mLeftCursorBG = a.getDrawable(R.styleable.RangeBar_leftCursorBackground);
    mRightCursorBG = a.getDrawable(R.styleable.RangeBar_rightCursorBackground);
    mTextColorNormal = a.getColor(R.styleable.RangeBar_textColorNormal, Color.GRAY);
    mRangeBarColorNormal = a.getColor(R.styleable.RangeBar_barColorNormal, Color.rgb(218, 215, 215));
    mRangeBarColorSelected = a.getColor(R.styleable.RangeBar_barColorSelected, Color.rgb(197, 0, 0));
    mRangeBarHeight = (int) a.getDimension(R.styleable.RangeBar_barHeight, 10);
    mTextSize = (int) a.getDimension(R.styleable.RangeBar_textSize, 14);
    mMarginBetween = (int) a.getDimension(R.styleable.RangeBar_spaceBetween, 16);
    isInfinite = a.getBoolean(R.styleable.RangeBar_isInfinite, true);

    CharSequence[] charArray = a.getTextArray(R.styleable.RangeBar_markTextArray);

    if (null == charArray || charArray.length <= 1) {
        throw new IllegalArgumentException("markTextArray should at least have 2 number!");
    }

    mTextArray = new int[isInfinite ? charArray.length + 1 : charArray.length];

    for (int i = 0; i < charArray.length; i++) {
        mTextArray[i] = Integer.parseInt(charArray[i].toString());
        if (mTextArray[i] < 0) {
            throw new IllegalArgumentException("markTextArray must be a positive number array");
        }
    }

    if (isInfinite) {
        mTextArray[charArray.length] = -1;
    }

    mLeftCursorIndex = 0;
    mRightCursorIndex = (mTextArray.length - 1) * 5;
    mRightCursorNextIndex = mRightCursorIndex;
    a.recycle();
}

From source file:com.woofer.activity.personHomeActivity.java

public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.LEFT;
    layoutParams.leftMargin = 30;//  w w w .  j a va  2  s  .co m
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {

        TableRow tableRow = new TableRow(this);
        TextView textView7 = new TextView(this);
        textView7.setText("" + i);
        textView7.setTextSize(18);
        textView7.setTextColor(Color.rgb(0, 0, 0));

        textView7.setPadding(15, 0, 15, 0);
        tableRow.addView(textView7, layoutParams);
        tableRow.setBackgroundColor(Color.WHITE);

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);

        TableRow tableRow1 = new TableRow(this);
        TextView textView1 = new TextView(this);
        textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i);
        textView1.setTextSize(16);
        textView1.setPadding(15, 0, 15, 15);
        tableRow1.addView(textView1, layoutParams);
        tableRow1.setBackgroundColor(Color.WHITE);

        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });
        mMainLayout.addView(tableRow1);

        //            TableRow tableRow2 = new TableRow(this);
        //            //tableRow2.addView(textView2, layoutParams);
        //            ImageView imageView = new ImageView(this);
        //            imageView.setImageResource(R.drawable.icon_reply_t);
        //            imageView.setScaleX((float) a);
        //            imageView.setScaleY((float) a);
        //            imageView.setPadding(0, 0, 0, 0);
        //
        //            ImageView imageView1 = new ImageView(this);
        //            imageView1.setImageResource(R.drawable.icon_thumb_t);
        //            imageView1.setScaleX((float) a);
        //            imageView1.setScaleY((float) a);
        //            imageView1.setPadding(0, 0, 0, 0);
        //
        //
        //            //tableRow2.addView(imageView);
        //            tableRow2.addView(imageView1);
        //            mMainLayout.addView(tableRow2);
        TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL);
        int numberOfRow = 1;
        int numberOfColumn = 12;
        int cellDimension = 24;
        int cellPadding = 200;
        for (int row = 0; row < numberOfRow; row++) {
            tableRow = new TableRow(this);
            //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
            tableRow.setLayoutParams(new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));

            for (int column = 0; column < numberOfColumn; column++) {
                if (column % 3 == 0) {
                    TextView textView = new TextView(this);
                    textView.setTextSize(20);
                    textView.setText("   ");
                    tableRow.addView(textView);
                }
                if (column % 3 == 1) {
                    if (column == 1) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_eye_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 4) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_thumb_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 7) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_reply_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 10) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_pencil_t);
                        tableRow.addView(imageView);
                    }
                }
                if (column % 3 == 2) {
                    if (column == 2) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 5) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 8) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 11) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                }

            }
            mytable.addView(tableRow, new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
            //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
        }

    }
}

From source file:com.glabs.homegenie.widgets.ColorLightRGBDialogFragment.java

@Override
public void refreshView() {
    super.refreshView();
    ////  w  ww.  j a  v a2  s. c om
    _view.post(new Runnable() {
        @Override
        public void run() {
            _groupText.setText(_module.getDisplayAddress());
            ModuleParameter levelParam = _module.getParameter("Status.Level");
            if (levelParam != null)
                _levelText.setText(_module.getDisplayLevel(levelParam.Value));
            else
                _levelText.setText("");
            ModuleParameter colorParam = _module.getParameter("Status.ColorHsb");
            if (colorParam != null && colorParam.Value != null) {
                try {
                    String[] sRgb = colorParam.Value.split(",");
                    int red = Integer.parseInt(sRgb[0]);
                    int green = Integer.parseInt(sRgb[1]);
                    int blue = Integer.parseInt(sRgb[2]);
                    int color = Color.rgb(red, green, blue);
                    _colorPicker.setColor(color);
                    _colorPreview.setBackgroundColor(color);
                } catch (Exception e) {
                    // TODO parsing errors
                }
            }
            //                _levelBar.setProgress((int)Math.round(_module.getDoubleValue(levelParam.Value) * 100));
        }
    });
}

From source file:com.example.copperadmin.tabformation.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*w  ww.java2  s. co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(Color.rgb(124, 148, 157));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.admin.activity.MultiTypeActivity.java

@Override
public void showBrandList(List<MultiTypeBean.ObjBean.BrandHomePageListBean> bean) {
    //?//from w ww.jav  a  2s  .com
    SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
    layoutHelper.setBgColor(Color.rgb(135, 225, 90));
    layoutHelper.setAspectRatio(4);
    layoutHelper.setMargin(10, 20, 10, 20);
    layoutHelper.setPadding(10, 10, 10, 10);
    adapters.add(new SubAdapter(this, layoutHelper, 1,
            new VirtualLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));

}

From source file:java_lang_programming.com.android_media_demo.article80.ImageFragment.java

/**
 * Bitmap??/*from w ww .j av a  2  s.c o m*/
 * NTSC ???
 * grayscale using Bitmap
 * NTSC Coef. method
 */
private void grayScaleNTSCCoefMethod() {
    long start = System.currentTimeMillis();
    Bitmap mutableBitmap = getMutableBitmap();

    int width = mutableBitmap.getWidth();
    int height = mutableBitmap.getHeight();
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {

            // Returns the Color at the specified location.
            int pixel = mutableBitmap.getPixel(i, j);

            int red = Color.red(pixel);
            int green = Color.green(pixel);
            int blue = Color.blue(pixel);

            // RGB ??
            double gray_scale_value = 0.2989 * red + 0.5870 * green + 0.1140 * blue;
            int gray_scale = (int) gray_scale_value;

            int gray_rgb = Color.rgb(gray_scale, gray_scale, gray_scale);

            mutableBitmap.setPixel(i, j, gray_rgb);
        }
    }
    imageView.setImageBitmap(mutableBitmap);
    long end = System.currentTimeMillis();
    Log.d(TAG, ((end - start) + "ms"));
}

From source file:edu.pdx.its.portal.routelandia.MapsActivity.java

/**
 * */*from  w ww. jav a  2  s .  co  m*/
 * @param highwayID: highway number
 * @return the pair color based on pair high
 */
private int generatePairhighWayColor(int highwayID) {
    int colorHighlightTheFreeWay = 0;
    if (highwayID == 9 || highwayID == 10) { //highway 210
        colorHighlightTheFreeWay = Color.rgb(255, 0, 0);
    } else if (highwayID == 5 || highwayID == 6) { //I-405
        colorHighlightTheFreeWay = Color.rgb(0, 255, 0);
    } else if (highwayID == 52 || highwayID == 53) { //highway 500
        colorHighlightTheFreeWay = Color.rgb(0, 0, 255);
    } else if (highwayID == 7 || highwayID == 8) { //I-84
        colorHighlightTheFreeWay = Color.rgb(0, 0, 0);
    } else if (highwayID == 11 || highwayID == 12) { //highway 26
        colorHighlightTheFreeWay = Color.rgb(255, 0, 255);
    } else if (highwayID == 50 || highwayID == 51) { //highway 14
        colorHighlightTheFreeWay = Color.rgb(255, 0, 0);
    } else if (highwayID == 3 || highwayID == 4) { //I-205 Oregon
        colorHighlightTheFreeWay = Color.rgb(128, 0, 255);
    } else if (highwayID == 501 || highwayID == 502) { //I-5 Washington
        colorHighlightTheFreeWay = Color.rgb(128, 0, 255);
    } else if (highwayID == 1 || highwayID == 2) { //I-5 Oregon
        colorHighlightTheFreeWay = Color.rgb(0, 128, 255);
    } else if (highwayID == 54 || highwayID == 55) { //I-205 Washington
        colorHighlightTheFreeWay = Color.rgb(0, 255, 0);
    }
    return colorHighlightTheFreeWay;
}

From source file:com.mchp.android.PIC32_BTSK.ColorFragment.java

@Override
public void onClick(View v) {

    int id = v.getId();
    if (id == R.id.red_down) {
        if (r > 0)
            r--;//from   ww w .  j  a  va  2  s .  c  om
    } else if (id == R.id.red_up) {
        if (r < seekBarMax)
            r++;
    } else if (id == R.id.green_down) {
        if (g > 0)
            g--;
    } else if (id == R.id.green_up) {
        if (g < seekBarMax)
            g++;
    } else if (id == R.id.blue_down) {
        if (b > 0)
            b--;
    } else if (id == R.id.blue_up) {
        if (b < seekBarMax)
            b++;
    } else {
    }

    mColor = Color.rgb(r, g, b);
    setProgressText();
    setSeekBarProgress();
    mColorPicker.setColor(mColor);
    mNewColor.setColor(mColor);

    sendLastColorLedCmd(r, g, b);

    return;
}