2015-02-24 50 views
0

这是我的绘制代码:机器人 - 为什么自定义绘制不影响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> 

这就是所谓的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。

我在做什么错?

+0

将此文本视图置于任何类型的布局中并设置背景为那个布局。 – iffu 2015-02-24 07:38:39

+0

@iffu没有工作,我试过了 – 2015-02-24 08:12:29

+0

好吧等待我现在工作,并给你的解决方案 – iffu 2015-02-24 08:14:17

回答

0

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

enter image description here

希望你可能会得到任何帮助。让我知道,如果它不工作...

享受编码... :)

+0

谢谢你的回复,没有背景颜色是不一样的,主要布局的背景是白色的.still不显示:( – 2015-02-24 07:58:18

+0

可以你请与我分享你的Java代码?你做错了什么。 – 2015-02-24 09:09:39

0

试试这个

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

代替

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

试试这个

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