0

I'm learning at XML and I made something like this:

              <TextView
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:background="@drawable/color1fp"
                android:gravity="center"
                android:text="Blah Blah"
                android:textColor="#1c469b"
                android:textSize="30sp"
                android:textStyle="italic" />

Where color1fp.xml is:

 <item android:state_pressed="true" >
    <shape>
        <solid
            android:color="#f7cd00" />
        <stroke
            android:width="1dp"
            android:color="#F1F1F1" />
        <corners
            android:radius="3dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>
<item>
    <shape>
        <gradient
            android:startColor="#f7cd00"
            android:endColor="#F1F1F1"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="#F1F1F1" />
        <corners
            android:radius="4dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

The result will be as a picture:

pic 1

My questions are:

  1. how can I make the borders look like this

  2. How can I make the two colors (yellow and white) transparent?

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
SaherS
  • 15
  • 4

1 Answers1

1

To accomplish the first point add this to your < shape > label:

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

To acompplish the second point you have to add alpha values to your hexa code for example, your yellow color is #f7cd00 and you can make it transparent as I said by adding 2 digits at the start: #AAf7cd00. You can see the values for transparency in this link

Community
  • 1
  • 1
Jonathan Aste
  • 1,764
  • 1
  • 13
  • 20