Example usage for android.graphics Paint Paint

List of usage examples for android.graphics Paint Paint

Introduction

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

Prototype

public Paint() 

Source Link

Document

Create a new paint with default settings.

Usage

From source file:asia.utopia.musicoff.view.PagerSlidingTabStrip.java

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

    setFillViewport(true);//w w w. j  av  a 2 s. c om
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_indicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_underlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_dividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_indicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_underlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_dividerPadding2, dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_tabBackground, tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_shouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_scrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_textAllCaps2, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.bdcorps.videonews.MainActivity.java

public void grabnews(String topicCode) {
    int pos = article;
    try {/*from  ww w  . ja v  a  2s.c o m*/

        JSONArray a = Config.initNewsRequest(topicCode);

        //  for (int i = 0; i<json.getInt("num_results");i++)
        {
            final JSONObject b = (JSONObject) a.get(article);
            JSONArray c = b.getJSONArray("multimedia");
            if (c.length() > 4) {
                JSONObject d = (JSONObject) c.get(4);
                String url = d.getString("url");
                final String title = b.getString("title");
                try {
                    new DownloadImageTask(new DownloadImageTask.AsyncResponse() {

                        @Override
                        public void processFinish(Bitmap result) {
                            Paint myRectPaint = new Paint();
                            int x1 = 0;
                            int y1 = 0;
                            int x2 = 500;
                            int y2 = 500;

                            //Create a new image bitmap and attach a brand new canvas to it
                            Bitmap tempBitmap = Bitmap.createBitmap(result.getWidth(), result.getHeight(),
                                    Bitmap.Config.RGB_565);
                            Canvas tempCanvas = new Canvas(tempBitmap);

                            //Draw the image bitmap into the cavas
                            tempCanvas.drawBitmap(result, 0, 0, null);

                            //Draw everything else you want into the canvas, in this example a rectangle with rounded edges
                            tempCanvas.drawRoundRect(new RectF(x1, y1, x2, y2), 2, 2, myRectPaint);
                            titleTextView.setText(title);
                            img.setImageBitmap(tempBitmap);
                        }
                    }, img).execute(url).get();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            text.setText(b.getString("abstract"));
                            Log.i("SSS", "abstract is = " + text.getText().toString());
                            canSpeak = true;
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });
            } else {

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getBaseContext(), "multimedia does not exist", Toast.LENGTH_LONG).show();
                    }
                });
                article++;
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*from   w  w  w  .  jav a  2 s.c o m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    tabBackgroundDrawable = createColorStateListDrawable(Color.TRANSPARENT,
            getResources().getColor(android.R.color.transparent));

    a.recycle();
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    if (a.hasValue(R.styleable.PagerSlidingTabStrip_pstsTabBackground))
        tabBackgroundDrawable = a.getDrawable(R.styleable.PagerSlidingTabStrip_pstsTabBackground);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    tabchecktextcolor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabCheckTextColor, tabchecktextcolor);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:de.tlabs.ssr.g1.client.SourcesView.java

private void init() {
    // make this view focusable
    setFocusable(true);//www .ja v a2 s.  c o  m

    // init fields
    viewportTransformation = new Matrix();
    newViewportTransformation = new Matrix();
    inverseViewportTransformation = new Matrix();

    selectionOffset = new float[2];
    touchPoint = new float[2];

    buffer = ByteBuffer.allocate(1024);

    scalingInterpolator = new TimedInterpolator();
    scalingInterpolator.setDuration(800);
    translationXInterpolator = new TimedInterpolator();
    translationXInterpolator.setDuration(800);
    translationYInterpolator = new TimedInterpolator();
    translationYInterpolator.setDuration(800);
    rotationInterpolator = new TimedInterpolator();
    rotationInterpolator.setDuration(800);
    centerRotationInterpolator = new TimedInterpolator();
    centerRotationInterpolator.setDuration(800);

    currentOrientation = getContext().getResources().getConfiguration().orientation;
    setOrientationFlag(true);

    if (SourcesView.paint == null) {
        SourcesView.paint = new Paint();
        SourcesView.paint.setAntiAlias(false);
        SourcesView.paint.setStrokeWidth(0);
        SourcesView.paint.setTextAlign(Paint.Align.CENTER);
        SourcesView.paint.setTextSize(9.0f);
    }

    // set up orientation event listener
    orientationEventListener = new OrientationEventListener(getContext(), SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            if ((orientation >= 80 && orientation <= 100) || (orientation >= 260 && orientation <= 280)) { // landscape
                setOrientation(Configuration.ORIENTATION_LANDSCAPE);
            } else if ((orientation >= 350 || orientation <= 10)
                    || (orientation >= 170 && orientation <= 190)) { // portrait
                setOrientation(Configuration.ORIENTATION_PORTRAIT);
            }
        }
    };
    if (!GlobalData.orientationTrackingEnabled) // orientation tracking and screen rotation tracking don't go together
        orientationEventListener.enable();

    // set up gesture detector
    gestureDetector = new GestureDetector(getContext(), this);
    gestureDetector.setIsLongpressEnabled(false);
    gestureDetector.setOnDoubleTapListener(this);

    // init viewport transformation matrix
    recalculateViewportTransformation();
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java

private void chart() {
    mLineChart = (LineChartView) v.findViewById(R.id.linechart);
    mLineChart.reset();/*from ww  w  .  ja  v  a2s  .  com*/
    dataSet = new LineSet();
    simpleArray = new float[weightLogAdapter.getCount()];
    dates = new String[weightLogAdapter.getCount()];
    for (int i = 0; i < weightLogAdapter.getCount(); i++) {
        WeightLog weightLogWeight = weightLogAdapter.getItem(i);
        simpleArray[i] = (float) weightLogWeight.getCurrentWeight();
        dates[i] = String.valueOf(DateFormat.format("MMM dd", weightLogWeight.getDate()));
    }
    dataSet.addPoints(dates, simpleArray);
    mLineGridPaint = new Paint();
    mLineGridPaint.setColor(this.getResources().getColor(R.color.accent));
    mLineGridPaint.setStyle(Paint.Style.FILL);
    mLineGridPaint.setAntiAlias(true);
    /**
     * Controlling the data set and setting it to the chart.
     */
    dataSet.setDots(true).setDotsColor(this.getResources().getColor(R.color.primary))
            .setDotsRadius(Tools.fromDpToPx(3)).setDotsStrokeThickness(Tools.fromDpToPx(1))
            .setDotsStrokeColor(this.getResources().getColor(R.color.primary))
            .setLineColor(this.getResources().getColor(R.color.primary_dark))
            .setLineThickness(Tools.fromDpToPx(1)).beginAt(0).endAt(weightLogAdapter.getCount());
    mLineChart.addData(dataSet);

    mLineChart.setBorderSpacing(Tools.fromDpToPx(0)).setGrid(LineChartView.GridType.HORIZONTAL, mLineGridPaint)
            .setXAxis(false).setXLabels(XController.LabelPosition.OUTSIDE).setYAxis(false)
            .setYLabels(YController.LabelPosition.OUTSIDE).setAxisBorderValues(min, max, 5)
            .setLabelColor(this.getResources().getColor(R.color.text_color))
            .setLabelsFormat(new DecimalFormat("##' lbs'")).show();

    Paint paint = new Paint();
    paint.setStrokeWidth((float) Equations.dpToPx(getActivity(), 2));
    paint.setColor(getActivity().getResources().getColor(R.color.green));
    mLineChart.setThresholdLine(goalWeightLine, paint);
}

From source file:android.improving.utils.views.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*w  ww  .  ja v  a  2s . co  m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    // tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    //tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);

    //?4
    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabTextSize, tabTextSize);
    tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabTextColor, tabTextColor);

    selectedTabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsSelectedTabTextSize,
            selectedTabTextSize);
    selectedTabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsSelectedTabTextColor,
            indicatorColor);

    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:edu.winlab.minijarvis.activity.CameraActivity.java

public void setRectPaint() {
    rectPaint = new Paint();
    rectPaint.setColor(Color.GREEN);
    rectPaint.setStyle(Paint.Style.STROKE);
    rectPaint.setStrokeWidth(5);/* w ww  .  jav a 2 s  .  c  o  m*/
}

From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java

private Bitmap RenderBarGraph(int CritCount, int ErrCount, int WarnCount) {

    //Log.i("Counts", Integer.toString(CritCount) + " / " + Integer.toString(ErrCount) + " / " + Integer.toString(WarnCount));
    Bitmap emptyBmap = Bitmap.createBitmap(290, 150, Config.ARGB_8888);

    int width = emptyBmap.getWidth();
    int height = emptyBmap.getHeight();
    Bitmap charty = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(charty);
    //final int color = 0xff0B0B61; 
    final Paint paint = new Paint();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(Color.WHITE);//from   w  w  w  .  j av a 2  s  . c o m

    //y
    canvas.drawLine(25, 0, 25, 289, paint);
    //x
    canvas.drawLine(25, 149, 289, 149, paint);

    paint.setAntiAlias(true);
    int Max = 0;

    if (CritCount > ErrCount && CritCount > WarnCount)
        Max = CritCount;
    else if (ErrCount > CritCount && ErrCount > WarnCount)
        Max = ErrCount;
    else if (WarnCount > CritCount && WarnCount > ErrCount)
        Max = WarnCount;
    else
        Max = CritCount;

    if (Max > 0)
        canvas.drawText(Integer.toString(Max), 0, 10, paint);

    if (Max > 1)
        canvas.drawText(Integer.toString(Max / 2), 0, 75, paint);

    canvas.drawText("0", 0, 148, paint);

    double divisor = 148 / (double) Max;

    paint.setAlpha(128);

    Rect rect = new Rect(32, (int) (148 - (divisor * CritCount)), 64, 148);
    paint.setColor(Color.argb(200, 208, 0, 0)); //red

    if (CritCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    rect = new Rect(128, (int) (148 - (divisor * ErrCount)), 160, 148);
    paint.setColor(Color.argb(200, 255, 102, 0));//orange

    if (ErrCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    rect = new Rect(224, (int) (148 - (divisor * WarnCount)), 256, 148);
    paint.setColor(Color.argb(200, 255, 224, 57)); //yellow
    if (WarnCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    //Return
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    charty.compress(CompressFormat.PNG, 50, out);

    return BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size());
}

From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // it removes the title from the actionbar(more space for icons?)
    // this.getActionBar().setDisplayShowTitleEnabled(false);

    pixels5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    LinearLayout parent = new LinearLayout(this);

    parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    parent.setOrientation(LinearLayout.VERTICAL);

    LinearLayout scrollViewParent = new LinearLayout(this);

    scrollViewParent.setLayoutParams(/*from ww  w. j a va 2  s  .co  m*/
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    scrollViewParent.setOrientation(LinearLayout.HORIZONTAL);

    HorizontalScrollView predictionsHorizontalScrollView = new HorizontalScrollView(this);
    //predictionsHorizontalScrollView.setLayoutParams(new ViewGroup.LayoutParams());

    predictions = new LinearLayout(this);
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER_VERTICAL;
    predictions.setLayoutParams(params);

    predictions.setOrientation(LinearLayout.HORIZONTAL);

    resetPredictionsView(predictions, true);
    predictionsHorizontalScrollView.addView(predictions);

    saveButton = new Button(this);
    saveButton.setText("Send Feedback");

    predictionsHorizontalScrollView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 10.0f));

    saveButton.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f));

    saveButton.setVisibility(View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(this);
    frameLayout
            .setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    frameLayout.addView(saveButton);

    loader = new ProgressBar(this);
    loader.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    loader.setIndeterminate(true);
    loader.setVisibility(ProgressBar.INVISIBLE);

    frameLayout.addView(loader);

    scrollViewParent.addView(predictionsHorizontalScrollView);
    scrollViewParent.addView(frameLayout);

    contentView = new MyView(this);
    parent.addView(scrollViewParent);
    parent.addView(contentView);

    setContentView(parent);

    otherLabelOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.e("Clicked", "Other Label label '" + (String) view.getTag() + "'");
            sendScreenshot(false, feedbackType, (String) view.getTag());
        }
    };

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(DEFAULT_BRUSH_SIZE);

    // Where did these magic numbers come from? What do they mean? Can I change them? ~TheOpenSourceNinja
    // Absolutely random numbers in order to see the emboss. asd! ~Valerio
    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);

    mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL);

    if (isFirstTime()) {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);

        alert.setTitle(R.string.app_name);
        alert.setMessage(R.string.app_description);
        alert.setNegativeButton(R.string.continue_button, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT)
                        .show();
            }
        });

        alert.show();
    } else {
        Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show();
    }

    loadFromIntents();
}

From source file:edu.winlab.minijarvis.activity.CameraActivity.java

public void setTextPaint() {
    textPaint = new Paint();
    textPaint.setColor(Color.GREEN);
    textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(60);/*from   w  ww.j a v  a  2s  . co  m*/
    textPaint.setTextAlign(Align.CENTER);
}