I'd like to be able to give any text view the same aspect as if it was disabled.
Currently I am using a style that inherits TextAppearance
and adds a gray text color, but I'd prefer using something built-in that would work flawlessly with any theme.
It's possible to preserve both the style of the view and the scrolling behaviour. To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.
This is the class for text whose content and markup can both be changed. This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). If you make a DynamicLayout of an Editable, the layout will be reflowed as the text is changed.
Android App Development for Beginners A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing.
define a selector with a disable like color and use it in layouts like this
In a color file (eg res/color/example.xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/disabled_color" />
<item android:color="@color/normal_color"/>
</selector>
then in your layout:
<TextView
android:text="whatever text you want"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/example" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With