在textview弄脏的意思号有自定义背景

时间:2018-06-13 11:15:56

标签: android xml

使用自定义背景创建textview时出现问题

这就是问题的样子:
this is how the problem looks like

我想让它看起来像这样:
i want to make it looks like this

这是我的textview XML代码

<TextView
        android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="4dp"
        android:textIsSelectable="true"
        android:layout_below="@+id/timestamp"
        android:background="@drawable/custom_bg"
        android:text=""
        android:textSize="14dp" />

这是我的custom_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid
        android:color="#E1E1E1" >
    </solid>


    <padding
        android:left="10dp"
        android:top="4dp"
        android:right="10dp"
        android:bottom="4dp"    >
    </padding>

    <corners
        android:radius="5dp"   >
    </corners>

</shape>

1 个答案:

答案 0 :(得分:1)

将颜色(透明以外的任何颜色)设置为textview,表情符号透明性问题得到解决:

textView.setTextColor(getResources().getColor(R.color.white));