Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hide text in a TextView?

Is there a way to hide some (but not all) of the text in a TextView? I tried setting the size to 0 with AbsoluteSizeSpan, but that doesn't have any visual effect that I see. (You can set the size to 1, and you essentially get bumpy lines instead of readable text. Cute, but not quite what I'm after.)

By hide, I mean go away, not be visible and not take up space. Drawing text with the same color as the background isn't what I'm looking for.

I realize I can just replace the text in the TextView with only the text I want to display, but I'm already using spans to do a lot more dynamic styling, and something like a HiddenSpan would be useful. Does it exist?

like image 986
James Moore Avatar asked Jul 11 '11 16:07

James Moore


People also ask

How do I hide text messages on my phone?

Hide Text messages 1 Open the Messages app on your Android. 2 Now, tap and hold the conversation you want to hide. A list of options will appear on top of the screen. 3 Click on the first icon in the row that resembles a folder with a downward pointing arrow. The selected conversation... More ...

How to hide private text messages on lockscreen without unlocking?

Tap on the Lock screen preferences under the Device security section. Now, click On lock screen and select Hide sensitive content. It will hide the message preview on lockscreen, and nobody will be able to read your private texts without unlocking your phone.

How do I turn off preview text messages on Android?

Open the Messaging app on your phone. Then, tap on the three dot icon in the upper right-hand corner to access the Settings menu. Tap on Notifications. Tap on In-app notification settings. Toggle the switch next to Preview new messages so that it turns off.

How can I protect my text messages from being tracked?

Vault is a security app which in addition to protecting your text messages from prying eyes, can also protect your photos, videos, apps, and bookmarks. To hide your text messages, you will need to select SMS and Contacts. From there, you can add contacts whose text messages you wish to be protected.


1 Answers

<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="0sp"
  android:textColor="@android:color/transparent" />

Transparent text color hides the visibility of the text. Add textSize to that to remove or minimize the space it takes up.

like image 184
gdub Avatar answered Oct 19 '22 22:10

gdub