當前位置:首頁 » 安卓系統 » android圓角textview

android圓角textview

發布時間: 2022-06-24 03:17:22

1. android 里用shape畫圓,怎麼填充顏色

Android裡面使用shape設置控制項的外形,例如一些圓角、填充的背景顏色、以及一些漸變的效果等,所以設置填充顏色,可通過設置shape.xml文件里的如下屬性:

<solidandroid:color="@color/common_red"/>

將shape文件放到android的button、textview組件上,就可以有填充背景顏色的效果,完整的代碼如下:

1.shape.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solidandroid:color="@color/common_red"/>
<padding
android:left="2dp"
android:top="1dp"
android:right="2dp"
android:bottom="1dp"/>
<solid
android:color="@color/common_red"/>
<stroke
android:width="1dp"
android:color="@android:color/white"/>
<sizeandroid:width="15dp"
android:height="15dp"/>
</shape>


2.把以上代碼添加到drawable裡面、通過background引用就可以了

<TextView
android:id="@id/message_category_unread_count"
style="@style/comm_text_style_14_aaaaaa"
android:layout_marginLeft="70dp"
android:layout_marginTop="5dp"
android:background="@drawable/shape"
android:gravity="center"
android:textSize="@dimen/text_size_comment_20"
android:text="7"
android:textColor="@android:color/white"/>

效果如下圖:

2. android不用shape怎麼給textview描邊

stroke:描邊
corners:圓角
padding:間隔

Shape的使用如下,製作橢圓形邊框textview_bg.xml。

[html] view plain
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="#ffffff" /> <!-- 定義填充的顏色值 -->

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:713
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:980
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:687
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:840
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:747
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1086
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:314
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:194
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:882
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:841