# textview

Published articles for textview.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Controlling TextView MinWidth

DevFeed: [Controlling TextView MinWidth](<https://devfeed.tech/articles/controlling-textview-minwidth-38652.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2021_09_14_controlling_textview_minwidth/>)

Published: 2021-09-14T00:00:00Z

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [constraintlayout](<https://devfeed.tech/topics/constraintlayout.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-layout](<https://devfeed.tech/tags/android-layout.md>), [background](<https://devfeed.tech/tags/background.md>), [constraintlayout](<https://devfeed.tech/tags/constraintlayout.md>), [gravity](<https://devfeed.tech/tags/gravity.md>), [layout](<https://devfeed.tech/tags/layout.md>), [properties](<https://devfeed.tech/tags/properties.md>), [textview](<https://devfeed.tech/tags/textview.md>), [xml](<https://devfeed.tech/tags/xml.md>)

### AI overview

A technical explanation of how Android TextView minimum-width APIs interact. Setting minWidth or minimumWidth alone may not reset a dimension declared in XML; both properties must be cleared, and a background can still impose a minimum width.

### Source excerpt

Introduction Sometimes we might need our TextView with wrap_content width to occupy more space than it will based on amount of characters it displays. For that we can set minimum width. Usually, we do that via XML like this: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bg_text" android:gravity="center" android:minWidth="200dp" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> Having setup like this we ensure that our TextView will occupy a minimum of 200dp. Also, we can control minimum width programmatically via: TextView#setMinWidth. But controlling minimum width programmatically has one caveat that I'd like to describe below.

## Avoiding fake italic and bold text on Android

DevFeed: [Avoiding fake italic and bold text on Android](<https://devfeed.tech/articles/avoiding-fake-italic-and-bold-text-on-android-29017.md>)

Original publisher: [Read original article](<https://saket.me/android-fake-vs-true-bold-and-italic/>)

Author: Saket Narayan

Published: 2019-12-18T00:08:59Z

Content type: tutorial

Language: en

Sources: [Saket Narayan](<https://devfeed.tech/sources/saket-narayan.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Font](<https://devfeed.tech/topics/font.md>), [formatting](<https://devfeed.tech/topics/formatting.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [fonts](<https://devfeed.tech/tags/fonts.md>), [formatting](<https://devfeed.tech/tags/formatting.md>), [legibility](<https://devfeed.tech/tags/legibility.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

This Android typography tutorial explains that fake bold and italic styling is produced when the platform cannot find the requested font variant. It describes the resulting effects on visual differentiation and legibility, and recommends applying the complete font family so true variants can be selected.

### Source excerpt

Changing line heights in Android using LineHeightSpan has this ugly side-effect where the cursor ends up being very tall, extending till the full line height instead of just the text height. I've decided to go to extreme lengths to fix this over the next few days. For science. pic.twitter.com/2tWLvDq1rz -- Saket Narayan (@Saketme) November 24, [...] The post Avoiding fake italic and bold text on Android appeared first on Saket Narayan.

## Displaying HTML tags on TextView the right way

DevFeed: [Displaying HTML tags on TextView the right way](<https://devfeed.tech/articles/displaying-html-tags-on-textview-the-right-way-29030.md>)

Original publisher: [Read original article](<https://saket.me/html-tags-textview/>)

Author: Saket Narayan

Published: 2017-06-29T12:59:12Z

Content type: tutorial

Language: en

Sources: [Saket Narayan](<https://devfeed.tech/sources/saket-narayan.md>)

Topics: [HTML](<https://devfeed.tech/topics/html.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [html](<https://devfeed.tech/tags/html.md>), [spans](<https://devfeed.tech/tags/spans.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

A tutorial explaining how Android parses and displays HTML in TextView. It compares TextView#setText(), Resources#getString(), Html.fromHtml(), and Html.fromHtml() with CDATA, emphasizing CharSequence and span objects as the mechanisms for rendering styled text.

### Source excerpt

While going through the codebase of a former client, I found that I was using four different ways for showing HTML on Android. This made me realize that I didn't really know what the correct way of showing them is and I've always hammered my way using trial & error until the HTML tags have showed up. Embarrassed, I decided to explore how [...] The post Displaying HTML tags on TextView the right way appeared first on Saket Narayan.

## A dive into Async-Await on Android

DevFeed: [A dive into Async-Await on Android](<https://devfeed.tech/articles/a-dive-into-async-await-on-android-25997.md>)

Original publisher: [Read original article](<https://medium.com/@nhaarman/a-dive-into-async-await-on-android-5a6699029aa3?source=rss-fceb7a60a849------2>)

Author: Niek Haarman

Published: 2016-11-03T16:09:29Z

Content type: tutorial

Language: en

Sources: [Stories by Niek Haarman on Medium](<https://devfeed.tech/sources/stories-by-niek-haarman-on-medium.md>)

Topics: [async/await](<https://devfeed.tech/topics/async-await.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Code](<https://devfeed.tech/topics/code.md>), [ui](<https://devfeed.tech/topics/ui.md>), [Network](<https://devfeed.tech/topics/network.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [await](<https://devfeed.tech/tags/await.md>), [blocking](<https://devfeed.tech/tags/blocking.md>), [callback](<https://devfeed.tech/tags/callback.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [database](<https://devfeed.tech/tags/database.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-compiler](<https://devfeed.tech/tags/kotlin-compiler.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [network](<https://devfeed.tech/tags/network.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

This tutorial explains async-await on Android using Kotlin coroutines, focusing on handling long-running network and database operations without blocking the UI thread. It contrasts nested callbacks with suspension functions such as asyncUI and await, and describes how the Kotlin compiler transforms the code.

### Source excerpt

Note: this article was written for a preview version of coroutines for Kotlin. Its details have changed since then. In a previous article I provided a glimpse into the world of async-await on Android. Now it's time to dive a little bit deeper in this upcoming functionality in Kotlin 1.1 What is async-await for? When dealing with long-running operations like network calls or database transactions, you need to make sure you schedule this work to a background thread. If you forget to do this, you may end up with blocking the UI thread until the task is finished. During that time, the user cannot interact with your application. Unfortunately when you schedule a new task in the background, you cannot use its result directly. Instead, you're gonna have to use some sort of callback. When that callback is invoked with the result of the operation, you can continue with what you want to do, for example run another network request. This easily flows in what people call a 'callback hell': multiple nested callbacks, all waiting to be invoked when some long-running task has finished. fun retrieveIssues() { githubApi.retrieveUser() { user -> githubApi.repositoriesFor(user) { repositories -> githubApi.issueFor(repositories.first()) { issues -> handler.post { textView.text = "You have issues!" } } } } } This snippet of code does three network requests, and finally posts a message to the main thread to update the text of some TextView. Fixing this with async-await With async-await, you can program that same function in a more imperative way. Instead of passing a callback to the function, you can call a suspension function await which lets you use the result of the task in a way that resembles normal synchronous code: fun retrieveIssues() = asyncUI { val user = await(githubApi.retrieveUser()) val repositories = await(githubApi.repositoriesFor(user)) val issues = await(githubApi.issueFor(repositories.first())) textView.text = "You have issues!" } This snippet of code still does three n

## A better way to handle links in TextView

DevFeed: [A better way to handle links in TextView](<https://devfeed.tech/articles/a-better-way-to-handle-links-in-textview-29018.md>)

Original publisher: [Read original article](<https://saket.me/better-url-handler-textview-android/>)

Author: Saket Narayan

Published: 2016-09-11T17:48:21Z

Content type: tutorial

Language: en

Sources: [Saket Narayan](<https://devfeed.tech/sources/saket-narayan.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [browser](<https://devfeed.tech/tags/browser.md>), [google-maps](<https://devfeed.tech/tags/google-maps.md>), [library](<https://devfeed.tech/tags/library.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

The article explains problems with Android's default LinkMovementMethod for clickable URLs in TextView, including incorrect touch areas, unreliable highlighting, and limited customization. It introduces BetterLinkMovementMethod as a drop-in replacement with custom URL-handling support.

### Source excerpt

There are two ways of "linkifying" URLs in a TextView. First, as an XML attribute: <TextView ... android:autoLink="phone|web" /> and second, programmatically: TextView textView = (TextView) findViewById(R.id.text1); Linkify.addLinks(textView, Linkify.PHONE_NUMBERS | LINKIFY.WEB_URLS); In both the cases, the framework internally registers a LinkMovementMethod on the TextView that handles dispatching a ACTION_VIEW Intent when any link is clicked. This is why phone-numbers open in a dialer when clicked, [...] The post A better way to handle links in TextView appeared first on Saket Narayan.

## The power of TextView (Part 1): Drawables

DevFeed: [The power of TextView (Part 1): Drawables](<https://devfeed.tech/articles/the-power-of-textview-part-1-drawables-27228.md>)

Original publisher: [Read original article](<https://antonioleiva.com/textview_power_drawables>)

Published: 2014-01-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [ui](<https://devfeed.tech/topics/ui.md>), [XML](<https://devfeed.tech/topics/xml.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [layout](<https://devfeed.tech/tags/layout.md>), [lint](<https://devfeed.tech/tags/lint.md>), [properties](<https://devfeed.tech/tags/properties.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

This Android tutorial explains how TextView compound drawables can place images beside text using drawableLeft, drawableRight, drawableTop, drawableBottom, and drawablePadding. It shows how this approach can replace a LinearLayout and ImageView, reducing layout complexity and simplifying XML.

### Source excerpt

Everything Android, Kotlin and other random topics

## Android Tips: Making a Custom Button out of Anything

DevFeed: [Android Tips: Making a Custom Button out of Anything](<https://devfeed.tech/articles/android-tips-making-a-custom-button-out-of-anything-30550.md>)

Original publisher: [Read original article](<https://ryanharter.com/blog/2013/03/android-tips-making-a-custom-button-out-of-anything/>)

Published: 2013-03-19T07:00:00Z

Content type: tutorial

Language: en

Sources: [Blogs on Ryan Harter](<https://devfeed.tech/sources/blogs-on-ryan-harter.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Large Screen](<https://devfeed.tech/topics/large-screen.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [interface](<https://devfeed.tech/tags/interface.md>), [java](<https://devfeed.tech/tags/java.md>), [layout](<https://devfeed.tech/tags/layout.md>), [textview](<https://devfeed.tech/tags/textview.md>)

### AI overview

This Android tutorial explains how to create custom buttons with both images and text without relying on complex layouts or invisible overlays. It describes using a LinearLayout with clickable behavior and button-state backgrounds as an alternative to the standard Button and ImageButton classes.

### Source excerpt

The Android APIs are filled with things that don't quite seem right. I've always been annoyed by the lack of relationship between interface elements. For instance, isn't a ListView really just a special case of a GridView with only one column? Yet GridView and ListView aren't directly related, so we get oddities where I can add header and footer views to a ListView, but not a GridView. One thing that seems to trip people up is the Button class. Android has a Button class for text (and images if your not really concerned with formatting them) and an ImageButton class for images. Like the ListView/GridView situation mentioned earlier, these two buttons are not, in fact, related. Button inherits from TextView and ImageButton inherits from ImageView.