Questions tagged [android-paint]

68 questions
15
votes
1 answer

Is there a way to fall back to Typeface.SERIF in a StaticLayout?

I'm creating a custom View class that displays text using a StaticLayout with a custom typeface loaded from a .ttf asset file. The basic look of the typeface is a serif font and the TrueType properties in the font file indicate that it's serif.…
Ted Hopp
  • 222,293
  • 47
  • 371
  • 489
7
votes
1 answer

Display TextView with 2 separate colors using mask

I am trying to achieve an effect similar to this one: What I am doing now: public MaskedTextView(Context context, AttributeSet attrs) { super(context, attrs); p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setTextSize(25); …
pat
  • 915
  • 3
  • 11
  • 27
4
votes
1 answer

How to Draw Rounded Rectangle in API Level below 21 on a Canvas

I am creating a custom view by extending android.view.View. Now, I need to draw a rounded rectangle on API level below 21. Android has a built in method name,drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint…
touhid udoy
  • 3,443
  • 2
  • 10
  • 29
4
votes
0 answers

android - how to create shadow effect from zeplin

I have a project in zeplin and I have many views / layouts with Shadows outer X 0dp Y 0dp Blur 10dp Shadows 0dp Color #000000 but I am not sure how to implement this in Android. How to specify blur shadow in Android along with a color?…
John61590
  • 1,066
  • 1
  • 12
  • 26
4
votes
2 answers

The Base64 of Bitmaps created on two different android devices is not identical

I create a bitmap after doing some canvas and paint operations and then Base64 encode it to a string. When I repeat the process on a separate device and compare the base64 encoded strings returned by the two devices, they are different. Any ideas on…
Vinay Gaba
  • 861
  • 3
  • 10
  • 23
4
votes
1 answer

Android PathDashPathEffect: the path shape does not work for a straight line

I am trying to build a custom view that draws a line with diagonal stripes pattern. It should look similar to this: I think using PathDashPathEffect should do, but when I set the path shape to be a straight line path, the view doesn't draw…
HeyThere
  • 307
  • 3
  • 16
4
votes
1 answer

Cut region out of Bitmap with Path

I'm trying to get cut a jigsaw puzzle piece out of an image, creating a new Bitmap image. I'm using a Path object to do this. This is the current result. And how I achived this Path path = new Path(); // Multiple path methods to create…
dumazy
  • 11,355
  • 12
  • 54
  • 100
3
votes
1 answer

How to draw text in all caps on Canvas

I am drawing text on my Canvas using TextPaint and StaticLayout. However, I want my text to be drawn in capital letters. The suggestion online is to use toUpperCase() but that change does not reflect on the canvas. This is my code: public void…
3
votes
2 answers

Android Paint Object Memory Efficency

Is android.graphics.Paint memory heavy object? Which one is more efficient, to pass paint object refrence to classes that need to draw on canvas and set paint properties such as color, style, etc. in those classes, or create new Paint object…
Thracian
  • 6,939
  • 2
  • 33
  • 64
2
votes
0 answers

use custom font in paint object typeface field

I have a custom font defined in my style file: I want to use it…
2
votes
2 answers

Can not set image resource of a custom imageview in Android

I have created a custom view project based on the lessons I have learned in this and this codelab. In my project, I tried to draw not just on a view but on a custom ImageView. Therefore, I have created a custom ImageView and did all the steps as in…
2
votes
1 answer

How to make Paint.breakText respect word wrapping?

I want to calculate how many lines some text needs to fit into a fixed-width TextView. And I used Paint.breakText for this: int maxWidth = WIDTH_IN_PIXELS; int index = 0; int linecnt = 0; while (true) { float[] measuredWidth = new float[1]; …
NeoWang
  • 13,687
  • 19
  • 61
  • 112
2
votes
1 answer

Android canvas doesn't draw the text on my bitmap

I'm trying to get the text input from the user and draw it on the image using Canvas but the image is saved without what was supposed to be drawn. Right now, I'm just trying to get the text on the Image before I worry about the font, colour,…
2
votes
6 answers

How to create a rectangle with two rounded corners?

I need to create a rectangle view with two rounded corners using canvas.I used drawRoundRect but i am getting rectangle with four rounded corners.Please anyone suggest me a way that can be helpful in solving my problem. rect = new RectF(left, top,…
2
votes
1 answer

Blend alpha of overlapped area without adding alpha

I don't know if what I'm asking is possible. I've a Paint with Color.BLACK with 0.2f of alpha and two objects: They both use the same Paint. I've also tested with 2 different Paint objects changing only the PorterDuffXfermode but I had no success.…
GuilhE
  • 10,723
  • 13
  • 63
  • 94
1
2 3 4 5