I have a TextView in my layout:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:text="Hello"
/>
textAllCaps works good, no problem. But when I try to make text selectable by adding textIsSelectable
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textIsSelectable="true"
android:text="Hello"
/>
textAllCaps not working. It seems like these two attributes can't work together properly. Have you any suggestions why it happens and how to make text both all caps and selectable (I'm interested in a most clear way, not setting text change listener and capitalizing text manually). I'll be appreciate for any suggestions, thank you.
Can you try this in Activity
:
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
I found one solution. It's to use AppCompatTextView and app:textAllCaps:
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textAllCaps="true"
android:textIsSelectable="true"
android:text="Hello"
/>
I'm not sure this is the best solution (AppCompatTextView docs tells to use this component only when creating custom components), but it works.
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