List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE IMAGE ROW/* w ww. ja v a2s . co m*/ * @param att * @param linear * @return */ public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f); ImageView img = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value")); img.setImageResource(context.getResources().getIdentifier(path, null, null)); img.setPadding(0, 3, 0, 3); container_layout.addView(img, value_params); linear.addView(container_layout); return linear; }
From source file:com.raspi.chatapp.util.Notification.java
private Bitmap getLargeIcon(char letter) { Random random = new Random(); int widthDP = 64; int bgColor = Color.rgb(random.nextInt(256), random.nextInt(256), random.nextInt(256)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return getLargeIcon(bgColor, letter, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, widthDP, context.getResources().getDisplayMetrics()), true); else/*from w w w .jav a 2s. co m*/ return getLargeIcon(bgColor, letter, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, widthDP, context.getResources().getDisplayMetrics()), false); }
From source file:com.esri.arcgis.android.samples.GeoJSONEarthquakeMap.GeoJSONEarthquakeMapActivity.java
private void getEarthquakeEvents() { int size;//from ww w . ja v a2 s . c o m String url = this.getResources().getString(R.string.earthquake_url); try { // Making the request and getting the response HttpClient client = new DefaultHttpClient(); HttpGet req = new HttpGet(url); HttpResponse res = client.execute(req); // Converting the response stream to string HttpEntity jsonentity = res.getEntity(); InputStream in = jsonentity.getContent(); String json_str = convertStreamToString(in); JSONObject jsonobj = new JSONObject(json_str); JSONArray feature_arr = jsonobj.getJSONArray("features"); SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.rgb(255, 128, 64), 15, SimpleMarkerSymbol.STYLE.CIRCLE); for (int i = 0; i < feature_arr.length(); i++) { // Getting the coordinates and projecting them to map's spatial // reference JSONObject obj_geometry = feature_arr.getJSONObject(i).getJSONObject("geometry"); double lon = Double.parseDouble(obj_geometry.getJSONArray("coordinates").get(0).toString()); double lat = Double.parseDouble(obj_geometry.getJSONArray("coordinates").get(1).toString()); Point point = (Point) GeometryEngine.project(new Point(lon, lat), SpatialReference.create(4326), mMapView.getSpatialReference()); JSONObject obj_properties = feature_arr.getJSONObject(i).getJSONObject("properties"); Map<String, Object> attr = new HashMap<String, Object>(); String place = obj_properties.getString("place").toString(); attr.put("Location", place); // Setting the size of the symbol based upon the magnitude float mag = Float.valueOf(obj_properties.getString("mag").toString()); size = getSizefromMag(mag); symbol.setSize(size); attr.put("Magnitude", mag); // Converting time from unix time to date format long timeStamp = Long.valueOf(obj_properties.getString("time").toString()); java.util.Date time = new java.util.Date((long) timeStamp); attr.put("Time ", time.toString()); attr.put("Rms ", obj_properties.getString("rms").toString()); attr.put("Gap ", obj_properties.getString("gap").toString()); // Add graphics to the graphic layer graphicsLayer.addGraphic(new Graphic(point, symbol, attr)); } } catch (ClientProtocolException e) { // Catch exceptions here e.printStackTrace(); } catch (IOException e) { // Catch exceptions here e.printStackTrace(); } catch (JSONException e) { // Catch exceptions here e.printStackTrace(); } }
From source file:v2.sierra.campitos.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)}.//from w w w . ja va 2s . 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); 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); //TIPOGRAFIA DE TEXTO DE LAS TABAS Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "Roboto-Light.ttf"); textView.setTypeface(typeface); textView.setPadding(padding, padding, padding, padding); textView.setTextColor(Color.rgb(255, 255, 255)); return textView; }
From source file:fr.cph.stock.android.activity.LoginActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void showProgress(final boolean show, String errorMessage) { // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow // for very easy animations. If available, use these APIs to fade-in // the progress spinner. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); mLoginStatusView.setVisibility(View.VISIBLE); mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override//from www.ja va 2s. co m public void onAnimationEnd(Animator animation) { mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); } }); mLoginFormView.setVisibility(View.VISIBLE); mLoginFormView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); } }); } else { // The ViewPropertyAnimator APIs are not available, so simply show // and hide the relevant UI components. mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); } if (!show) { errorView.setText(errorMessage); errorView.setTextColor(Color.rgb(160, 0, 0)); } }
From source file:com.progym.custom.fragments.WaterProgressYearlyLineFragment.java
public void setLineData3(final Date date, final boolean isLeftIn) { final ProgressDialog ringProgressDialog = ProgressDialog.show(getActivity(), getResources().getString(R.string.please_wait), getResources().getString(R.string.populating_data), true);// w ww .j a v a 2s . c o m ringProgressDialog.setCancelable(true); new Thread(new Runnable() { @Override public void run() { try { int yMaxAxisValue = 0; getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { rlRootGraphLayout.removeView(mChartView); } catch (Exception edsx) { edsx.printStackTrace(); } } }); DATE = date; // 31 - Amount of days in a month int daysInMonth = Utils.getDaysInMonth(date.getMonth(), Integer.valueOf(Utils.formatDate(date, DataBaseUtils.DATE_PATTERN_YYYY))); // set January as first month date.setMonth(0); date.setDate(1); int[] x = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; // Creating an XYSeries for Consumed water XYSeries consumedSeries = new XYSeries("Consumed"); List<WaterConsumed> list; // int userShouldConsume = (int) DataBaseUtils.getWaterUserShouldConsumePerDay(); Date dt = date; // * // Adding data to Income and Expense Series for (int i = 0; i < x.length; i++) { // get all water records consumed per this month list = DataBaseUtils.getAllWaterConsumedInMonth( Utils.formatDate(dt, DataBaseUtils.DATE_PATTERN_YYYY_MM)); // init "average" data int averageWaterConsumedOnYaxis = 0; for (int j = 0; j < list.size(); j++) { // calculate sum of all water consumed by user in a month averageWaterConsumedOnYaxis += list.get(j).volumeConsumed; } averageWaterConsumedOnYaxis = averageWaterConsumedOnYaxis / daysInMonth; consumedSeries.add(i, averageWaterConsumedOnYaxis); // normaSeries.add(i, userShouldConsume); dt = DateUtils.addMonths(dt, 1); yMaxAxisValue = Math.max(yMaxAxisValue, averageWaterConsumedOnYaxis); } // Creating a dataset to hold each series final XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); // Adding Expense Series to dataset // dataset.addSeries(normaSeries); // Adding Income Series to the dataset dataset.addSeries(consumedSeries); // Creating XYSeriesRenderer to customize incomeSeries XYSeriesRenderer incomeRenderer = new XYSeriesRenderer(); incomeRenderer.setColor(Color.rgb(50, 255, 50)); incomeRenderer.setFillPoints(true); incomeRenderer.setLineWidth(2); incomeRenderer.setDisplayChartValues(true); /* * // Creating XYSeriesRenderer to customize expenseSeries * XYSeriesRenderer expenseRenderer = new XYSeriesRenderer(); * expenseRenderer.setColor(Color.rgb(80, 220, 80)); * expenseRenderer.setFillPoints(true); * expenseRenderer.setLineWidth(2); * expenseRenderer.setDisplayChartValues(true); */ // Creating a XYMultipleSeriesRenderer to customize the whole chart final XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(); multiRenderer.setXLabels(0); for (int i = 0; i < x.length; i++) { multiRenderer.addXTextLabel(i, ActivityWaterProgress.months_short[i]); } // Adding incomeRenderer and expenseRenderer to multipleRenderer // Note: The order of adding dataseries to dataset and renderers to multipleRenderer // should be same multiRenderer.setChartTitle(String.format("Water statistic for %s year", Utils.formatDate(DATE, DataBaseUtils.DATE_PATTERN_YYYY))); multiRenderer.setXTitle("Months"); multiRenderer.setYTitle("Water volume (ml)"); multiRenderer.setAxesColor(Color.WHITE); multiRenderer.setShowLegend(true); multiRenderer.addSeriesRenderer(incomeRenderer); multiRenderer.setShowGrid(true); multiRenderer.setClickEnabled(true); // multiRenderer.addSeriesRenderer(expenseRenderer); multiRenderer.setXLabelsAngle(30); // multiRenderer.setBackgroundColor(Color.parseColor("#B3FFFFFF")); // multiRenderer.setApplyBackgroundColor(true); multiRenderer.setXLabelsColor(Color.WHITE); multiRenderer.setZoomButtonsVisible(false); // configure visible area multiRenderer.setXAxisMax(11.5); multiRenderer.setXAxisMin(-0.5); multiRenderer.setYAxisMax(yMaxAxisValue + (yMaxAxisValue / 5)); multiRenderer.setYAxisMin(-0.1); multiRenderer.setAxisTitleTextSize(15); multiRenderer.setBarSpacing(0.1); multiRenderer.setZoomEnabled(true); getActivity().runOnUiThread(new Runnable() { @Override public void run() { mChartView = ChartFactory.getBarChartView(getActivity(), dataset, multiRenderer, Type.DEFAULT); rlRootGraphLayout.addView(mChartView, 0); if (isLeftIn) { rightIn.setDuration(1000); mChartView.startAnimation(rightIn); } else { leftIn.setDuration(1000); mChartView.startAnimation(leftIn); } } }); } catch (Exception e) { e.printStackTrace(); } ringProgressDialog.dismiss(); } }).start(); }
From source file:com.shine.demo.viewpager.smartTabLayout.SmartTabLayout.java
public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); final DisplayMetrics dm = getResources().getDisplayMetrics(); final float density = dm.density; int tabBackgroundResId = NO_ID; boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS; ColorStateList textColors;/*from w w w . ja va2 s . c o m*/ float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm); int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density); int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density); boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY; int customTabLayoutId = NO_ID; int customTabTextViewId = NO_ID; boolean clickable = TAB_CLICKABLE; int titleOffset = (int) (TITLE_OFFSET_DIPS * density); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0); tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId); textAllCaps = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps); textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor); textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize); textHorizontalPadding = a.getDimensionPixelSize( R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding); textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth); customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId); customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId); distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly); clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable); titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset); a.recycle(); this.titleOffset = titleOffset; this.tabViewBackgroundResId = tabBackgroundResId; this.tabViewTextAllCaps = textAllCaps; this.tabViewTextColors = (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR); this.tabViewTextSize = textSize; this.tabViewTextHorizontalPadding = textHorizontalPadding; this.tabViewTextMinWidth = textMinWidth; this.internalTabClickListener = clickable ? new InternalTabClickListener() : null; this.distributeEvenly = distributeEvenly; if (customTabLayoutId != NO_ID) { setCustomTabView(customTabLayoutId, customTabTextViewId); } this.tabStrip = new SmartTabStrip(context, attrs); if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) { throw new UnsupportedOperationException( "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support"); } this.tabViewTextColors = new ColorStateList( new int[][] { new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_selected }, new int[] {} }, new int[] { Color.rgb(255, 111, 51), Color.rgb(255, 111, 51), Color.parseColor("#222222") }); // Make sure that the Tab Strips fills this View setFillViewport(!tabStrip.isIndicatorAlwaysInCenter()); addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
From source file:org.rockettrack.MapFragment.java
@Override protected void onRocketLocationChange() { if (mMap == null) { return;//w w w . j a v a2 s .co m } Location rocketLocation = getRocketLocation(); if (rocketLocation == null) return; LatLng rocketPosition = new LatLng(rocketLocation.getLatitude(), rocketLocation.getLongitude()); //Draw marker at Rocket position if (rocketMarker == null) { BitmapDescriptor rocketIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_rocket_map); rocketMarker = mMap .addMarker(new MarkerOptions().anchor(0.5f, 0.5f).position(rocketPosition).icon(rocketIcon)); } else { rocketMarker.setPosition(rocketPosition); } if (rocketCircle == null) { CircleOptions options = new CircleOptions().center(rocketPosition).radius(rocketLocation.getAccuracy()) .strokeColor(Color.RED).strokeWidth(1.0f).fillColor(Color.RED & 0x22FFFFFF); rocketCircle = mMap.addCircle(options); } else { rocketCircle.setCenter(rocketPosition); rocketCircle.setRadius(rocketLocation.getAccuracy()); } updateBearing(); List<Location> rocketLocationHistory = getRocketLocationHistory(); if (rocketLocationHistory != null && rocketLocationHistory.size() > 0) { List<LatLng> rocketPosList = new ArrayList<LatLng>(rocketLocationHistory.size()); for (Location l : rocketLocationHistory) { rocketPosList.add(new LatLng(l.getLatitude(), l.getLongitude())); } if (rocketPath == null) { rocketPath = mMap.addPolyline(new PolylineOptions().width(1.0f).color(Color.rgb(0, 0, 128))); } rocketPath.setPoints(rocketPosList); } //Draw line between myPosition and Rocket updateRocketLine(rocketLocation, rocketPosition); }
From source file:org.exoplatform.ui.social.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }/*from ww w . j a v a 2 s .co m*/ mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { TabView child = (TabView) mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); /* * Set text color in case of selected */ if (isSelected) { child.setTextColor(Color.rgb(65, 65, 65)); animateToTab(item); } else child.setTextColor(Color.rgb(120, 120, 120)); } }
From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java
public void onServiceContainerClick(View v) { v.setBackgroundColor(isServiceSelected ? Color.rgb(255, 255, 255) : Color.rgb(236, 104, 0)); ((ImageView) findViewById(R.id.imgCheckbox2)) .setImageResource(isServiceSelected ? R.drawable.check_field : R.drawable.check_in_orange); ((ImageView) findViewById(R.id.imgService)).setImageResource( isServiceSelected ? R.drawable.service_pump_icon_gray : R.drawable.service_pump_icon_white); textService.setTextColor(isServiceSelected ? getResources().getColor(R.color.DarkGrey) : Color.WHITE); if (isServiceSelected) getMapFragment().overlaysManager.removeServiceStations(); else/* w ww . j a v a2s.c om*/ getMapFragment().overlaysManager.drawServiceStations(this); isServiceSelected = !isServiceSelected; }