On an App screen I have a number of EditText views. My app is built using the Material Design (AppCompactActivity, etc).
While showing an EditText field, with a long press I try to select a number of words in the text. This allows me to copy or share that text. Selecting more than 1 word seems not possible.
Since the migration to Material Design I see 2 things:
1 - After a long press there are no selection handles shown. So, on the place of the question marks I expected inverse waterdrops. These are the handles you normally use to change the particular selection.
Question: why are these reverse eyedrops gone? I do see them when selecting text in e.g. a webview.
Yes, I use 'android:textIsSelectable="true"'. Below you see the EditText layout.
2 - The "sharing" option for the selected text is not available. Why?
What is the EditText field?
<EditText
android:id="@+id/geocache_info_hint"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:singleLine="false"
android:lines="4"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:layout_marginLeft="5dp"
android:ellipsize="none"
android:textIsSelectable="true"
android:text=""/>
Upon selection of a text (in this case 1 word) what I also see is that an extra bar 'tekstselectie' (=textselection) is put on top of the screen. That's also a difference since Android 4.
** Solution **
In my theme I had a line that caused the problem of not showing any text selection handles:
<item name="android:popupBackground">@color/window_background</item>
The @color/window_background was chosen as white.
Upd2:
Also, as tjm1706 figured out, it's important to carefully review the Theme property. In this case, the key was to remove <item name="android:popupBackground">@color/window_background</item>
Upd1:
To avoid this "double-toolbar" on editing, add this to your Theme's style:
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">@drawable/myapp_action_mode_background</item>
taken from here
To add Share (or any other button) - you need to set on your EditText
setCustomSelectionActionModeCallback
:
Check out this question: Custom cut/copy action bar for EditText that shows text selection handles - it contains detailed example.
Original:
Try to remove: android:textIsSelectable="true"
. It's not possible to type with it. And if you don't need EditText
to be editable - probably, simple TextView
suits you better.
Without it, your EditText
works fine for me:
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