0

When I use TextView to display a text, and set the background color for a example to grey, then the displayed text looks absorbed by this background color. So my idea was to add the TextView to CardView, give the Cardview the backgroundColor, and set the elevation of TextView higher then CardView, but it is still the same. I even tried to add in CardView a Layout with Textview inside and set the elevation of the Layout higher. I want the displayed text floating above the View. Do someone have an idea how to solve that problem?

Here is a screenshot of what I mean. When you look on the elements you can see a slim layer (lamination) of grey over the smileys: https://drive.google.com/file/d/1W2E6Ivom0WEyrTtqBeLu1Z3rtHdMXKKS/view?usp=drivesdk

And here is the last code:

<androidx.cardview.widget.CardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAlignment="viewEnd"
    android:layout_gravity="end"
    android:layout_margin="6dp"
    app:cardCornerRadius="5dp"
    android:elevation="20dp"
    android:background="#80817c">



<TextView 
    android:textSize="18sp"
    android:textAlignment="viewEnd"
    android:layout_gravity="end"
    android:id="@+id/user_ping"
    android:layout_margin="5dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:text="siema"
    android:elevation="25dp"/>
</androidx.cardview.widget.CardView>
Zoe
  • 27,060
  • 21
  • 118
  • 148
Koala
  • 29
  • 7
  • Have you tried setting the `TextView` and `Cardview` elevations to be equal? E.g. 0dp for both. [this doc](https://developer.android.com/guide/topics/ui/layout/cardview#create_cards) seems to suggest that the shadow is dependent on the elevation difference between the elements in the layout. – Yassie Apr 23 '19 at 08:38
  • I tried that, it is still the same. And it make more sense to set the elevation of TextView higher then the CardView. But please make an simple experiment. Create a TextView with the same background color as me, and push a smiley to the TextView, you will see what I mean. And when you see that, you will see that even a simple text looks shadowy. – Koala Apr 23 '19 at 11:02

1 Answers1

0

Okay, I got the solution. You have to give the text a shadow effect, then the text appears clear and without the background color lamination.

Koala
  • 29
  • 7