繁体   English   中英

android - 为什么自定义drawable不影响textview

[英]android -Why custom drawable not effecting textview

这是我的可绘制代码:

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

    <corners
        android:bottomLeftRadius="7dp"
        android:bottomRightRadius="7dp"
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp" />

    <solid android:color="#3C1251" />
</shape>

这是我的drawable文件夹中名为haraj.xml的xml文件。

这是我的xml布局:

<TextView 
        android:id="@+id/harajamount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:gravity="center"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="15dp"
        android:textColor="#fff"
        android:textSize="15sp"
        android:padding="8dp"
        android:background="@drawable/haraj"
        android:text="2500"
        />

奇怪的是,它不会影响textview。 我得到没有背景颜色和没有角落的textview。

我究竟做错了什么?

你现在的背景是什么? 希望它不会是#3C1251。 因为我刚试过你的代码。 它的工作完美,并为textview提供适当的背景颜色。

在此输入图像描述

希望你能得到任何帮助。 如果它不起作用,请告诉我......

享受编码...... :)

尝试这个

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

代替

<corners
        android:bottomLeftRadius="7dp"
        android:bottomRightRadius="7dp"
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp" />

尝试这个

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

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

    <solid android:color="#3C1251" />

    <size android:height="23dp" />

</shape>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM