Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText Selection Anchors Missing

I've just noticed that all my EditText fields in my app do not show the selection anchors correctly. For example:

Image with no selection anchors

However, what I expect is the correct anchors to appear such as:

Image with selection anchors

A typical example of an affected EditText in my app:

<EditText
    android:id="@+id/text_message"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@id/button_send"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:inputType="text|textShortMessage"
    android:layout_marginRight="4dp"
    android:hint="@string/hint_chat_send" />

Also notice that the "paste" hover view has a strange white border around it in my app, but in other apps it is completely transparent.

I suspect some kind of theme issue, since it affects multiple screens in my app, but I cannot find info on which attributes may cause this.

UPDATE

So, I've spent a few way too many hours debugging the EditText, TextView, and Editor framework classes to no avail. Everything appears to be functioning as expected.

I created a new blank Activity in the same application with the following layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <EditText
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:hint="test" />

</RelativeLayout>

In my other screens, I am using the AppCompat library and it's related themes, but in this Activity I overrode the theme and the Activity to be a stock Android Activity with the built-in Material theme:

public class TestActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {

    setTheme(android.R.style.Theme_Material_Light_NoActionBar);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_test);
}
...

It's my understanding calling setTheme in this manner should override any possible customizations from my app styles.xml. Still, I see this:

Markers not shown on simulator

Kind of at a loss here still...

like image 586
Jeffrey Mixon Avatar asked Jul 16 '15 21:07

Jeffrey Mixon


1 Answers

The solution is to remove android:popupBackground which I had set in my theme:

<!-- This will break the text selection popup -->
<item name="android:popupBackground">@color/not_quite_white</item>

I had this set to try and theme all the Spinner dropdown backgrounds to the same color. For whatever reason, it interferes with the text selection popup. Furthermore, calling Activity.setTheme apparently did not override this property, leading to some confusion.

like image 190
Jeffrey Mixon Avatar answered Oct 03 '22 00:10

Jeffrey Mixon