Set the color parameter in Android code

Source: Internet
Author: User
Tags getcolor

Today you want to draw a curve that changes dynamically based on the color of the parameter, and the parameters are not fixed, so you need to get the color values based on the parameters. Studied for a long time and engaged in a scheme that was implemented through paint.

Paint contains a number of ways to set its properties, the main method is as follows:

Setantialias: Sets the brush's jagged effect.
setcolor: Setting Brush colors
Setargb: Sets the a,r,p,g value of the brush.
Setalpha: Setting alpha value
settextsize: Sets the font size.
SetStyle: Sets the brush style, hollow or solid.
setstrokewidth: Sets the hollow border width.
getColor: Get the color of the brush

Getalpha: Gets the alpha value of the brush.


All we need is SETARGB and getcolor.

private int GetColor (float yourparam) {int Alfa = 120;int Rcolor = 255;int Gcolor = 255;int Bcolor = 255;/********* * Your Code, change alfa/r/g/b by yourparam *********/paint paint = new Paint ();p Aint.setargb (Alfa, Rcolor, Gcolor, bcolor); Retu RN Paint.getcolor ();}

Set the color parameter in Android code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.