Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android text selection handles have white background (instead of transparent)

The following screenshot shows my problem:

enter image description here

The text selection handles have a white background and overlay other UI elements. How can I make the background transparent?

Or the better question is actually: what could I possibly have done to make the background white?

Here is the style applied to the EditText:

<style name="TextInputLayout" parent="AppTheme">
    <item name="android:background">@color/grey_50</item>
    <item name="colorControlNormal">@color/grey_500</item>
    <item name="colorControlActivated">@color/grey_900</item>
    <item name="colorControlHighlight">@color/grey_900</item>
    <item name="backgroundTint">@color/grey_900</item>
    <item name="colorAccent">@color/grey_900</item>
    <item name="colorPrimary">@color/grey_900</item>
    <item name="android:textCursorDrawable">@null</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/grey_500</item>
    <item name="colorPrimaryDark">@color/grey_500</item>
    <item name="colorAccent">@color/grey_700</item>
    <item name="android:colorBackground">@color/grey_50</item>
    <item name="android:colorForeground">@color/grey_900</item>
    <item name="android:textColorPrimary">@color/grey_900</item>
    <item name="android:textColorPrimaryInverse">@color/grey_50</item>
    <item name="android:textColorSecondary">@color/grey_900</item>
    <item name="android:textColorSecondaryInverse">@color/grey_50</item>
    <item name="android:windowBackground">@color/grey_50</item>
    <item name="android:textColorHint">@color/grey_700</item>
    <item name="android:colorActivatedHighlight">@color/grey_900</item>
    <item name="colorControlNormal">@color/grey_700</item>
    <item name="colorControlActivated">@color/grey_900</item>
    <item name="colorControlHighlight">@color/grey_900</item>
    <item name="android:textColorHighlight">@color/grey_500</item>
    <item name="android:colorControlNormal" tools:targetApi="lollipop">@color/grey_700</item>
    <item name="android:colorControlActivated" tools:targetApi="lollipop">@color/grey_900</item>
    <item name="android:colorControlHighlight" tools:targetApi="lollipop">@color/grey_900</item>
    <item name="android:stateListAnimator" tools:targetApi="lollipop">@null</item>
    <item name="android:statusBarColor" tools:targetApi="lollipop">@color/grey_900</item>
    <item name="android:navigationBarColor" tools:targetApi="lollipop">@color/grey_900</item>
</style>

Edit #1

The EditText's XML (note that I see the same behaviour with EditTexts and AppCompatEditTexts):

<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_home_autocomplete"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/activity_horizontal_margin_small"
    android:layout_marginTop="@dimen/activity_horizontal_margin_small"
    android:layout_weight="3.5"
    android:background="@null"
    android:hint="@string/location"
    android:padding="@dimen/activity_vertical_margin_medium"
    android:theme="@style/TextInputLayout"
    app:hintAnimationEnabled="true"
    app:hintEnabled="true"
    app:hintTextAppearance="@style/TextAppearance.TextInputLayout">

    <AutoCompleteTextView
        android:id="@+id/user_home_autocomplete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="3.5"
        android:dropDownWidth="match_parent"
        android:inputType="textAutoComplete"
        android:maxLines="1"
        android:paddingTop="@dimen/activity_horizontal_margin_small" />

</android.support.design.widget.TextInputLayout>

The Phone I used for the screenshot runs Android 6.0.1 with OxygenOS 3.2.7

Getting rid of all @null elements did not work.

like image 204
Barthy Avatar asked Nov 24 '16 22:11

Barthy


People also ask

How do you change the background color on Kotlin?

To set Android Button background color, we can assign android:backgroundTint XML attribute for Button in layout file with the required Color Value. To programmatically set or change Android Button background color, we may call pass the method Button.


1 Answers

This could happen if you set a background color in your main theme , something like this

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="android:background">@color/white</item>
    ...
 </style>

remove this property solve this issue for me , if you want to setup a background for all your screens set windowBackground instead.

<item name="android:windowBackground">@color/white</item>
like image 153
Osarez Avatar answered Sep 19 '22 23:09

Osarez