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:com.xosp.nilac.changelog.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.slide_menu_activuty);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   w  w  w  . j a v  a2s . c o m*/

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setBackgroundColor(Color.rgb(39, 174, 96));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, R.string.xosp_contact_title, Snackbar.LENGTH_LONG)
                    .setActionTextColor(Color.rgb(39, 174, 96))
                    .setAction(R.string.xosp_contact_summary, new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Uri uriUrl = Uri.parse("mailto:xperiaopensourceproject@gmail.com");
                            Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
                            startActivity(intent);
                        }
                    }).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    setImageConnection();
}

From source file:com.example.domiter.fileexplorer.dialog.BaseDialogFragment.java

/**
 * Overrides tint set with tintDrawable().
 */// w w  w .ja v  a  2s.  c o m
private Drawable lightenDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    Drawable newDrawable = drawable.getConstantState().newDrawable().mutate();
    newDrawable
            .setColorFilter(new LightingColorFilter(Color.rgb(255, 255, 255), Color.argb(200, 255, 255, 255)));

    return newDrawable;
}

From source file:org.lol.reddit.views.PostListingHeader.java

public PostListingHeader(final Context context, final String titleText, final String subtitleText) {

    super(context);

    final float dpScale = context.getResources().getDisplayMetrics().density;

    setOrientation(LinearLayout.VERTICAL);

    final int sidesPadding = (int) (15.0f * dpScale);
    final int topPadding = (int) (10.0f * dpScale);

    setPadding(sidesPadding, topPadding, sidesPadding, topPadding);

    final Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");

    final TextView title = new TextView(context);
    title.setText(StringUtils.abbreviate(titleText, 33));
    title.setTextSize(22.0f);//from   w  w w .j  a  v  a 2 s. c o  m
    title.setTypeface(tf);
    title.setTextColor(Color.WHITE);
    addView(title);

    final TextView subtitle = new TextView(context);
    subtitle.setTextSize(14.0f);
    subtitle.setText(StringUtils.abbreviate(subtitleText, 50));
    subtitle.setTextColor(Color.rgb(200, 200, 200));
    addView(subtitle);

    setBackgroundColor(Color.rgb(50, 50, 50)); // TODO theme color
}

From source file:com.manuelpeinado.numericpageindicator.demo.StylingProgrammaticallyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new MyPagerAdapter());
    pageIndicator = (NumericPageIndicator) findViewById(R.id.pageIndicator);
    pageIndicator.setViewPager(viewPager);

    pageIndicator.setTextTemplate("Page: #i");
    pageIndicator.setStartButtonText("|<");
    pageIndicator.setPreviousButtonText("<");
    pageIndicator.setNextButtonText(">");
    pageIndicator.setEndButtonText(">|");
    pageIndicator.setTextColor(Color.argb(128, 255, 255, 255));
    pageIndicator.setPageNumberTextColor(Color.argb(192, 255, 255, 255));
    pageIndicator.setPageNumberTextBold(false);
    final float scale = getResources().getDisplayMetrics().density;
    pageIndicator.setTextSize((int) (12 * scale + 0.5f));
    pageIndicator.setTopPadding((int) (7 * scale + 0.5f));
    pageIndicator.setBottomPadding((int) (7 * scale + 0.5f));
    pageIndicator.setBackgroundColor(Color.rgb(64, 96, 64));
    pageIndicator.setPressedButtonColor(Color.argb(128, 255, 255, 255));
    pageIndicator.setShowChangePageButtons(true);
}

From source file:com.jjoe64.graphview_demos.fragments.BatteryLife.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_battery_graph, container, false);

    GraphView graph = (GraphView) rootView.findViewById(R.id.graph);
    BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(1, 5), });
    series.setColor(Color.rgb(158, 1, 66));
    series.setSpacing(0);//from   w  ww.  j  av a  2 s.  c  o m
    graph.addSeries(series);

    BarGraphSeries<DataPoint> series2 = new BarGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(2, 5) });
    series2.setColor(Color.rgb(213, 62, 79));
    series2.setSpacing(0);
    graph.addSeries(series2);

    //        BarGraphSeries<DataPoint> series3 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(3,5)
    //        });
    //        series3.setColor(Color.rgb(244, 109, 67));
    //        series3.setSpacing(0);
    //        graph.addSeries(series3);
    //
    //
    //        BarGraphSeries<DataPoint> series4 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(4,4)
    //        });
    //        series4.setColor(Color.rgb(253, 174, 97));
    //        series4.setSpacing(0);
    //        graph.addSeries(series4);
    //
    //
    //        BarGraphSeries<DataPoint> series5 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(5,4)
    //        });
    //        series5.setColor(Color.rgb(254, 224, 139));
    //        series5.setSpacing(0);
    //        graph.addSeries(series5);
    //
    //        BarGraphSeries<DataPoint> series6 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(6,3)
    //        });
    //        series6.setColor(Color.rgb(230, 245, 152));
    //        series6.setSpacing(0);
    //        graph.addSeries(series6);
    //
    //        BarGraphSeries<DataPoint> series7 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(7,4)
    //        });
    //        series7.setColor(Color.rgb(171, 221, 164));
    //        series7.setSpacing(0);
    //        graph.addSeries(series7);
    //
    //        BarGraphSeries<DataPoint> series8 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(8,5)
    //        });
    //        series8.setColor(Color.rgb(102, 194, 165));
    //        series8.setSpacing(0);
    //        graph.addSeries(series8);
    //
    //        BarGraphSeries<DataPoint> series9 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(9,5)
    //        });
    //        series9.setColor(Color.rgb(0, 136, 189));
    //        series9.setSpacing(0);
    //        graph.addSeries(series9);
    //
    //        BarGraphSeries<DataPoint> series10 = new BarGraphSeries<DataPoint>(new DataPoint[] {
    //                new DataPoint(10,3)
    //        });
    //        series10.setColor(Color.rgb(94, 79, 162));
    //        series10.setSpacing(20);
    //        graph.addSeries(series10);

    graph.getViewport().setXAxisBoundsManual(true);
    graph.getViewport().setMinX(0);
    graph.getViewport().setMaxX(4);
    graph.getViewport().setYAxisBoundsManual(true);
    graph.getViewport().setMinY(0);
    graph.getViewport().setMaxY(5);
    StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
    staticLabelsFormatter.setHorizontalLabels(new String[] { "", "" });
    staticLabelsFormatter.setVerticalLabels(new String[] { "low", "med", "high" });
    graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);

    GridLabelRenderer gridLabel = graph.getGridLabelRenderer();
    gridLabel.setHorizontalAxisTitle("Sensors");
    gridLabel.setVerticalAxisTitle("Battery Life");

    // legend
    series.setTitle("region");
    series2.setTitle("lesson");
    //        series3.setTitle("life");
    //        series4.setTitle("sensorial");
    //        series5.setTitle("letters");
    //        series6.setTitle("blocks");
    //        series7.setTitle("washing");
    //        series8.setTitle("buttons");
    //        series9.setTitle("tea");
    //        series10.setTitle("snack");
    graph.getLegendRenderer().setVisible(true);
    graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);

    return rootView;
}

From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    // Create the "Step N of T" TextView
    TextView stepTextView = new TextView(this.context);
    stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    stepTextView.setTextColor(Color.rgb(113, 113, 113));
    stepTextView.setGravity(Gravity.CENTER);
    stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1,
            this.solution.size()));

    // Create the boar with the current step of the solution
    BoardCanvas board = new BoardCanvas(this.context);
    board.setBoardRepresentation(this.solution.get(position).getBoard());
    board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(),
            this.solution.get(position).getDirection());

    // Add the components to the layout
    LinearLayout layout = new LinearLayout(this.context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(16, 20, 16, 16);//from www  . jav a  2  s  . c om

    RelativeLayout relativeLatout = new RelativeLayout(this.context);
    relativeLatout.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    relativeLatout.addView(board);

    layout.addView(relativeLatout);
    layout.addView(stepTextView);
    ((ViewPager) collection).addView(layout, 0);
    return layout;
}

From source file:com.layer.atlas.messenger.MessengerPushReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (debug)/*from w w  w. j  av  a  2s.com*/
        Log.w(TAG, "onReceive() action: " + intent.getAction() + ", extras: "
                + MessengerApp.toString(intent.getExtras(), "\n", "\n"));
    if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
        if (debug)
            Log.w(TAG, "onReceive() Waking Up! due to action: " + intent.getAction());
        return;
    }

    NotificationManager notificationService = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    String text = intent.getStringExtra("layer-push-message");
    Uri conversationId = (Uri) intent.getExtras().get("layer-conversation-id");
    String title = getTitle(context, conversationId);
    if (title == null)
        title = context.getResources().getString(R.string.app_name);

    Notification.Builder bld = new Notification.Builder(context);
    bld.setContentTitle(title).setContentText(text).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
            .setLights(Color.rgb(0, 255, 0), 100, 1900)
            .setDefaults(NotificationCompat.DEFAULT_SOUND | NotificationCompat.DEFAULT_VIBRATE);

    Intent chatIntent = new Intent(context, AtlasMessagesScreen.class);
    chatIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    chatIntent.putExtra(keys.CONVERSATION_URI, conversationId.toString());

    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, chatIntent,
            PendingIntent.FLAG_ONE_SHOT);

    bld.setContentIntent(resultPendingIntent);

    final Notification notification = bld.getNotification();

    try {
        // Group notifications by Conversation
        notificationService.notify(conversationId.hashCode(), notification);
    } catch (SecurityException ignored) {
        // 4.1.2 device required VIBRATE permission when in Vibrate mode. 
        // Fixed in 4.2.1 https://android.googlesource.com/platform/frameworks/base/+/cc2e849
    }
}

From source file:com.jjoe64.graphview_demos.fragments.StylingBarGraph.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    GraphView graph = (GraphView) rootView.findViewById(R.id.graph);
    BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, -1),
            new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) });
    graph.addSeries(series);/*ww w .  ja va2  s .com*/

    // styling
    series.setValueDependentColor(new ValueDependentColor<DataPoint>() {
        @Override
        public int get(DataPoint data) {
            return Color.rgb((int) data.getX() * 255 / 4, (int) Math.abs(data.getY() * 255 / 6), 100);
        }
    });

    series.setSpacing(50);

    // draw values on top
    series.setDrawValuesOnTop(true);
    series.setValuesOnTopColor(Color.RED);
    //series.setValuesOnTopSize(50);

    // legend
    series.setTitle("foo");
    graph.getLegendRenderer().setVisible(true);
    graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);

    return rootView;
}

From source file:com.ryan.ryanreader.views.SubredditHeader.java

public SubredditHeader(final Context context, final RedditSubreddit subreddit) {

    super(context);

    final float dpScale = context.getResources().getDisplayMetrics().density;

    setOrientation(LinearLayout.VERTICAL);

    final int sidesPadding = (int) (15.0f * dpScale);
    final int topPadding = (int) (10.0f * dpScale);

    setPadding(sidesPadding, topPadding, sidesPadding, topPadding);

    final Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");

    final TextView title = new TextView(context);
    title.setTextSize(22.0f);//www  .j av  a  2 s.c  om
    title.setTypeface(tf);
    title.setText(StringEscapeUtils.unescapeHtml4(subreddit.title));
    title.setTextColor(Color.WHITE);
    addView(title);

    final TextView subs = new TextView(context);
    subs.setTextSize(14.0f);

    if (subreddit.subscribers == null) {
        subs.setText("Subscriber count is unknown");
    } else {
        subs.setText(NumberFormat.getNumberInstance(Locale.getDefault()).format(subreddit.subscribers)
                + " subscribers");
    }

    subs.setTextColor(Color.rgb(200, 200, 200));
    addView(subs);

    setBackgroundColor(Color.rgb(50, 50, 50)); // TODO theme color
}

From source file:com.google.android.gms.example.apidemo.DFPAppEventsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mAdView = (PublisherAdView) getView().findViewById(R.id.appevents_av_main);

    mAdView.setAppEventListener(new AppEventListener() {
        @Override/*  w  ww.j a  va2  s  . c  o  m*/
        public void onAppEvent(String name, String data) {

            // The DFP ad that this fragment loads contains JavaScript code that sends App
            // Events to the host application. This AppEventListener receives those events,
            // and sets the background of the fragment to match the data that comes in.
            // The ad will send "red" when it loads, "blue" five seconds later, and "green"
            // if the user taps the ad.

            // This is just a demonstration, of course. Your apps can do much more interesting
            // things with App Events.

            if (name.equals("color")) {
                switch (data) {
                case "blue":
                    mRootView.setBackgroundColor(Color.rgb(0xD0, 0xD0, 0xFF));
                    break;
                case "red":
                    mRootView.setBackgroundColor(Color.rgb(0xFF, 0xD0, 0xD0));
                    break;
                case "green":
                    mRootView.setBackgroundColor(Color.rgb(0xD0, 0xFF, 0xD0));
                    break;
                }
            }
        }
    });

    PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
    mAdView.loadAd(adRequest);
}