Home > Mobile >  Highlighted text in CardView has no color
Highlighted text in CardView has no color

Time:10-17

I have a TextView inside a Cardview. The TextView has the property android:textIsSelectable="true", so I am able to highlight text. The problem is that there is no color to the highlight. Setting android:textColorHighlight did not work either.

CodePudding user response:

I am able to see selected colour using textIsSelectable="true" and "textColorHighlight" attributes. Here is my code:

<com.google.android.material.card.MaterialCardView
    android:id="@ id/mainCard"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardElevation="2dp"
    app:layout_constraintTop_toTopOf="parent">
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
          android:id="@ id/textView"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          android:text="This is a Text View"
          android:textColorHighlight="#ff00ff"
          android:textIsSelectable="true"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

enter image description here

  • Related