TextView和CardView内部的文本外观

TextView和CardView内部的文本外观

本文介绍了TextView和CardView内部的文本外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用TextView显示文本并将示例的背景色设置为灰色时,显示的文本看起来会被该背景色吸收.所以我的想法是将TextView添加到CardView,为Cardview提供backgroundColor,并将TextView的高度设置为比CardView高,但是仍然相同.我什至尝试在CardView中添加一个内部带有Textview的布局,并设置更高的布局高度.我希望显示的文本浮动在视图上方.有人知道如何解决该问题吗?

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?

这是我的意思的屏幕截图.当您查看这些元素时,您会在笑脸上看到一个薄薄的灰色层(分层): https://drive.google.com/file/d/1W2E6Ivom0WEyrTtqBeLuKKSZ/3tHdMX view?usp = drivesdk

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

这是最后一个代码:

<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>

推荐答案

好的,我已经解决了.您必须给文本加上阴影效果,然后文本显示清晰且没有背景色分层.

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.

这篇关于TextView和CardView内部的文本外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 02:00