2013-05-22 76 views
0

我在我的應用程序中有一個EditText .. EditText突出了漂亮的角落。TextView中的突出顯示的文本

我想用類似於我的EditText的高亮文本來做類似的TextView。有一個例子: My nice highlighted EditText

是否有可能使用html或我應該使用畫布?如果可以使用畫布,你可以舉幾個例子嗎?

UPD:我想要閃耀文本。像這樣 - Example

+0

您可以使用9色標圖像,並設置爲backgroundresource http://developer.android.com/reference/android/view/View.html#attr_android:background到TextView的 –

+0

你想圓的文本視圖角落? – Raghunandan

+0

我想要閃耀文字。像這樣 - [例子](http://www.darkscarab.com/resources/tutorials/images/72/000.jpg) – Vetalll

回答

0

您還可以使用九個補丁圖像作爲您的textview的背景。

Border over a bitmap with rounded corners in Android

您可以使用選擇並設置TextView的背景。沒有必要使用html或canvas。

bkg.xml在繪製文件夾

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

設置背景

 android:background="@drawable/bkg" 

enter image description here

+0

沒有..我想要閃耀文本。像這樣 - [例子](http://www.darkscarab.com/resources/tutorials/images/72/000.jpg) – Vetalll

+0

@ Vetal.lebed做一個9補丁圖像,並設置爲相同的背景就像鏈接你在評論中提到 – Raghunandan