Text appearance, inside TextView and CardView

ぐ巨炮叔叔 提交于 2019-12-08 09:39:40

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/55798755/text-appearance-inside-textview-and-cardview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!