Questions tagged [paint]

The act of displaying a GUI component on a screen output device

Painting is the act of displaying a GUI component on a screen output device, and is responsible for visually representing the component object to the user. For example, displaying a Button object should paint a 'button' shape on the screen, with the text or icon that relates to the button.

2808 questions
193
votes
10 answers

How do I suspend painting for a control and its children?

I have a control which I have to make large modifications to. I'd like to completely prevent it from redrawing while I do that - SuspendLayout and ResumeLayout aren't enough. How do I suspend painting for a control and its children?
Simon
  • 25,468
  • 44
  • 152
  • 266
114
votes
7 answers

android set custom font to a paint

I want to draw a text to a paint. How to draw it with a custom font (ex Helvetica ) and bold also? I would preffer to use a system font and not create it from assets. Thanks.
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
102
votes
3 answers

How did this person code "Hello World" with Microsoft Paint?

I have just seen this within the past few days and cannot figure out how it works. The video I talk about is here: It's the top rated answer from this Stack Overflow question: Why was this program rejected by three compilers? How is this bitmap…
Eamonn O'Brien
  • 1,085
  • 2
  • 8
  • 3
86
votes
3 answers

How do I draw bold text on a Bitmap?

I want a Bitmap icon with bold text to draw it on map. I have a snippet to write text on image: Bitmap icon = BitmapFactory.decodeResource(PropertyMapList.this.getResources(), R.drawable.location_mark); TextPaint paint = new…
Sampath Kumar
  • 4,433
  • 2
  • 27
  • 42
62
votes
3 answers

Drawing a filled rectangle with a border in android

Is there any way in Android to draw a filled rectangle with say a black border. My problem is that the canvas.draw() takes one paint object, and to my knowledge the paint object can't have a different color for the fill and the stroke. Is there a…
Uwais Iqbal
  • 910
  • 1
  • 8
  • 14
51
votes
4 answers

Is there already a canvas drawing directive for AngularJS out there?

Is there already a directive to draw/paint things on a canvas? So you can implement something like Paint or even something bigger like Photoshop etc., but a very basic example would suffice. I haven't found one in my search and if there's already…
justGoscha
  • 24,085
  • 15
  • 50
  • 61
39
votes
1 answer

setShadowLayer Android API differences

I develop a custom view component for my application and I am struggling with adding a shadow to a circle. Here is the code of my class extending View public class ChartView extends View { public ChartView(Context context, AttributeSet…
Al_th
  • 1,174
  • 1
  • 12
  • 24
36
votes
2 answers

How to draw smooth / rounded path?

I am creating Paths and adding multi lines in each path by using path.moveTo(x, y) and path.lineTo(x, y). Then canvas.drawPath(path, paint) is drawing all paths. But there are 1-2 pixel space between lines in some paths. How can I remove these…
Onuray Sahin
  • 4,093
  • 4
  • 33
  • 34
36
votes
1 answer

Android Paint stroke width positioning

Given this code to draw a line: Paint p; p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setColor(android.graphics.Color.WHITE); p.setStyle(Paint.Style.FILL); p.setStrokeWidth(21); canvas.drawLine(0,50,100,50,p); there are 3 possible stroke-drawing…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
36
votes
7 answers

Implementing smooth sketching and drawing on the element

I am trying to create a drawing area with canvas. I am having trouble with making the lines look smooth when drawing curves and I also have changing line thickness in my algorithm which looks bad as well because the size jumps to much as well and…
ryuutatsuo
  • 3,924
  • 3
  • 27
  • 29
33
votes
6 answers

How to draw text with different stroke and fill colors?

I want to display text as below in my app. I am using Paint class with style FILL_AND_STROKE to achieve this. But only one method setColor() is available to set the color. How do I set different stroke and fill colors?
Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
32
votes
5 answers

How to set paint.setColor(R.color.white)

I have a custom View that uses Paint and Canvas to draw objects. My question is how to set: int color = R.color.white; paint.setColor(color); from my /res/valuse/color.xml which includes resources like
Vasil Valchev
  • 5,701
  • 2
  • 34
  • 39
31
votes
1 answer

Dynamically generated line with glow effective

I want to draw line with glow effect like this The problem - i must generate this line in program in dependence on user's interaction ( the form of line will be generated in onTouchEvent - ACTION_MOVE ). Can i generate this effect without xml…
sharl
  • 1,257
  • 1
  • 12
  • 17
29
votes
4 answers

In Android Studio message "Paint.setShadowLayer.. graphics not accurate.." without this code

I get this message in android studio xml preview: "The graphics preview in the layout editor may not be accurate: -Paint.setShadow is not supported." Without having this line of code at all in my project. Also I tried to run "Edit-Find-Find in Path"…
Yuval Levy
  • 2,397
  • 10
  • 44
  • 73
28
votes
5 answers

Tickmark algorithm for a graph axis

I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark. For example, given that I need to display between 1e-6 and 5e-6 and a width…
Nick
  • 13,238
  • 17
  • 64
  • 100
1
2 3
99 100