0

I have an EditText in my app.. EditText has highlighted nice corner.

I want to do similar TextView with nice highlighted text like my EditText. There is an example: My nice highlighted EditText

Is it possible to do it with html or i should use canvas? If it possible with canvas can you give me few examples?

UPD: I want shine Text. something like this - Example

Vetalll
  • 3,472
  • 6
  • 24
  • 34

1 Answers1

0

You can also use a nine patch image as a background for your textview.

Border over a bitmap with rounded corners in Android

You can use a selector and set the background of the textview. There is no need to use html or canvas.

bkg.xml in drawable folder

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true" 
    android:drawable="@drawable/pressed" />
 <item  android:state_focused="false" 
    android:drawable="@drawable/normal" />
 </selector>

normal.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="#FFFFFF"/>    
<stroke android:width="3dp"

<padding android:left="5dp"
         android:top="5dp"
         android:right="5dp"
         android:bottom="5dp"/> 
    <corners android:bottomRightRadius="7dp"
         android:bottomLeftRadius="7dp" 
         android:topLeftRadius="7dp"
         android:topRightRadius="7dp"/> 
         </shape>

pressed.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="#FF1A47"/>    
<stroke android:width="3dp"
        android:color="#0FECFF"/>
<padding android:left="5dp"
         android:top="5dp"
         android:right="5dp"
         android:bottom="5dp"/> 
<corners android:bottomRightRadius="7dp"
         android:bottomLeftRadius="7dp" 
         android:topLeftRadius="7dp"
         android:topRightRadius="7dp"/> 
</shape>

Set background of your text view as

     android:background="@drawable/bkg"

enter image description here

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • No.. I want shine Text. something like this - [Example](http://www.darkscarab.com/resources/tutorials/images/72/000.jpg) – Vetalll May 22 '13 at 06:48
  • @Vetal.lebed make a 9 patch image and set the same as background just like the link you mentioned in the comment – Raghunandan May 22 '13 at 09:17