For a short label in a custom Android view, configure an android.graphics.Paint and call Canvas.drawText(). Its y coordinate is the text baseline, not the top of the visible letters. Use Paint alignment and font metrics to position a single line; use StaticLayout for paragraphs and Canvas.drawTextOnPath() for text that follows a curve.
Draw a single line with Canvas.drawText()
Set up a reusable Paint before drawing, then pass it to drawText() along with the text and the x and y coordinates. The coordinates are in the Canvas’s current coordinate system, which may be affected by transformations applied to the Canvas. Android canvas coordinates increase downward.
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.BLACK
textSize = 48f
textAlign = Paint.Align.LEFT
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
canvas.drawText("Hello, Android", 24f, 80f, textPaint)
}
In this example, (24, 80) is the left-aligned text origin and baseline. The visible glyphs usually extend above and below that baseline. Canvas.drawText() API reference documents the available text overloads and their origin behavior; Paint API reference describes text-related Paint settings.
Position text accurately
Center a line horizontally
Set textAlign to Paint.Align.CENTER and supply the x coordinate where the text should be centered. For example, use canvas.width / 2f to center it in the Canvas’s current width. The y coordinate remains the baseline.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 【Strong Adsorption】The inspiration of the silicone phone suction case comes from the adhesive force of the octopus. Each suction cup phone mount is 3.15 inches long and 2.17 inches wide, with 24 independent suction cups providing a stronger and more stable suction force, so you don't have to worry about your phone falling during use.
- 【Back of Phone Suction Grip】Remove the adhesive film on the phone suction cup and stick it on the phone case. You can then fix the phone on any smooth surface, which is very convenient. (The phone suction cup cannot be removed and reused after being attached to the phone case. It is recommended to attach it to a regular phone case, not a valuable one.)
- 【Widely Used】Our non-slip silicone phone sticky grip mount attaches to almost any flat phone case and make it compatible with common mobile phones such as iPhone and Android.You can shoot, watch videos or video calls in the kitchen, gym, dance studio, bathroom and other places.
- 【Capture the Wonderful Picture】Whether you are a TikTok creator or just like to share videos and photos, this phone suction cup can help you hands-free capture wonderful videos and photos for sharing with friends.
- 【Note】You can fix the phone suction cup on a smooth surface such as a mirror or glass. If necessary, wipe the suction cup with a damp cloth to obtain stronger suction. Before releasing your hand, make sure the phone is firmly fixed. (Not applicable to rough walls, wooden surfaces, and other uneven surfaces)
textPaint.textAlign = Paint.Align.CENTER
canvas.drawText("Centered label", canvas.width / 2f, baselineY, textPaint)
Center a line vertically in a region
Use the font metrics from the same Paint used to draw the text. For the usual ascent and descent metrics, calculate the baseline as centerY - (ascent + descent) / 2, where centerY is the vertical midpoint of the region. Ascent is normally negative and descent positive because both are measured relative to the baseline; subtracting their average accounts for that sign convention.
val metrics = textPaint.fontMetrics
val centerY = (regionTop + regionBottom) / 2f
val baselineY = centerY - (metrics.ascent + metrics.descent) / 2f
canvas.drawText("Vertically centered", centerX, baselineY, textPaint)
Paint.FontMetrics also exposes top, bottom, and leading for other metric-based spacing decisions. These values describe font extents, not a guarantee that every individual glyph fills the measured area. See the Paint.FontMetrics API reference.
Rank #2
- SUPERIOR COMFORT — Unlike traditional circular ear buds, the design of EarPods is defined by the geometry of the ear. Which makes them more comfortable for more people than any other ear bud–style headphones.
- HIGH-QUALITY AUDIO — The speakers inside EarPods have been engineered to maximize sound output and minimize sound loss, which means you get high-quality audio.
- BUILT-IN REMOTE — EarPods with USB-C plug also include a built-in remote that lets you adjust the volume, control the playback of music and video, and answer or end calls with a pinch of the cord.
- COMPATIBILITY — Works with all devices that have a USB-C port.
- INTEGRATED MICROPHONE — A built-in microphone precisely captures your voice while you’re on the phone, taking a FaceTime call, or summoning Siri — so you’re always heard loud and clear.
Draw paragraphs and multiple lines with StaticLayout
drawText() draws the string or character range you pass; it does not automatically wrap a paragraph into lines. For multiline text, create a text Layout, such as StaticLayout, and draw that layout on the Canvas. The layout handles line composition within its configured width rather than treating the paragraph as one long direct-drawing call.
// Sketch: construct a StaticLayout for the text, Paint, and available width.
// Then position the Canvas and draw the layout.
canvas.save()
canvas.translate(left, top)
staticLayout.draw(canvas)
canvas.restore()
Choose the layout width and alignment to match the text region. The StaticLayout API reference documents drawing and desired-width measurement, while the Layout API reference covers layout drawing and text bounds. Constructor availability and deprecation details vary by Android API level and library context, so check the reference documentation for the versions your app supports when selecting a constructor.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRank #3
- Secure Hold: Our PopSockets adhesive phone grip gives your cell phone a secure, comfortable hold in hand to help prevent drops while texting, taking photos, or scrolling on the go. Designed to stick firmly to most phone cases and devices.
- Hands-Free Made Easy: Easily turn your PopSocket into a phone stand to prop up your phone anywhere, perfect for watching videos, video calls, or following recipes. A must-have phone holder that keeps your device secure and ready for anything.
- Compatibility: Works with all phones, tablets, and Kindles. Sticks best to smooth, hard plastic cases and may not adhere to silicone or textured cases. Easily swap your PopTop to change up your style.
- Black PopSockets: Simple, refined, and endlessly versatile. A timeless essential for any phone.
- Travel Must-Have for People On the Go: A must-have travel accessory for flights, flying, airports, air travel, airplanes, planes, international trips, cruises, and long travel days. Key gadget for your airport haul, travel accessories and must-haves.
Draw text along a path
For a curved or otherwise shaped text baseline, create a Path and pass it to Canvas.drawTextOnPath(). The text follows the path baseline; this API does not create a text box that automatically wraps.
val baselinePath = Path().apply {
moveTo(40f, 160f)
quadTo(200f, 40f, 360f, 160f)
}
canvas.drawTextOnPath("Text follows this curve", baselinePath, 0f, 0f, textPaint)
The horizontal offset moves the text along the path, and the vertical offset positions it above or below the path. Paint alignment controls the text’s starting position relative to the path. See the Canvas API reference for the overloads and offset behavior.
Quick Recap
Best Value
- 【PKYAA Double Sided Silicone Suction Phone Case Mount】PKYAA With Double Sided 40 Strong and Reliable individual suction cups, PKYAA provides a thicken and upgraded universal silicon suction mount for your phone.
- 【Friendly to Content Creators】If you are a content creator or an online influencer, you can create videos anywhere with this suction mount completely hands free with this silicone cell phone mount for cases.
- 【HANDS-FREE & Adhere to Mirrors】This Double Sided silicone suction phone case mount allows you to stick your phone to the mirror easily. No longer holding your phone in one hand to watch video tutorials while making up.
- 【Strong Grip on the Smooth Surface】You can easily hang your phone anywhere with a smooth surface. All you do is you clean off your phone and smooth surface. It is STURDY and it not only sticks to mirrors, it also sticks to windows, it sticks to refrigerators, tiles and other clean, flat surfaces.
- 【Press Down Firmly Every 30 Minutes】Use your palm or fingers to press the phone down firmly and check it's secure before letting go. Apply even pressure for a few seconds to allow the suction cup to adhere properly. To maintain the grip and prevent accidental falls, it's a good practice to periodically reapply pressure to the suction cup.
Rank #4
- [360 ° Flexible Rotation Design] Comes with a rotatable lanyard ring that supports 360 ° free rotation, effectively solving the problem of twisted and tangled lanyards
- [Wide compatibility] The ultra-thin 0.02-inch design does not block the charging port at all, and both wired and wireless charging can be used directly without removing the pad. Compatible with most smartphones such as iPhone, compatible with various wristbands, lanyards, crossbody straps, and keychains
- [Durable and Portable Material] Premium rust-resistant stainless steel material with good flexibility, which not only avoids scratching the phone case, but also has excellent anti rust and anti fading performance
- [Multi scenario Practical] Paired with a lanyard or wristband, hands-free use can be achieved. The phone is within reach and not easily dropped, ideal for daily commuting and outdoor activities. Suitable for full coverage phone cases, does not support half coverage phone cases
- [Quality Service] If you find any damage or other issues with the product upon receipt, please contact us immediately. We will handle it quickly
Choose the drawing method by text shape
| Text to draw | Use | Positioning controls |
|---|---|---|
| One line or a selected character range | Canvas.drawText() |
Baseline coordinates and Paint alignment |
| Paragraph or multiple lines | Layout, such as StaticLayout |
Layout width and alignment; draw the layout on the Canvas |
| Text on a curve or shaped baseline | Canvas.drawTextOnPath() |
Path, horizontal and vertical offsets, and Paint alignment |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

