當前位置:首頁 » 安卓系統 » 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" /> <!-- 定義填充的顏色值 -->

熱點內容
2008文件伺服器搭建教程 發布:2025-07-02 18:03:14 瀏覽:51
離線androidapi文檔 發布:2025-07-02 18:02:23 瀏覽:144
阿里雲伺服器查看流量 發布:2025-07-02 17:44:42 瀏覽:838
c怎麼編譯c程序 發布:2025-07-02 17:30:58 瀏覽:293
安卓手機變成蘋果手機怎麼保存 發布:2025-07-02 17:20:24 瀏覽:192
負源碼怎麼算 發布:2025-07-02 16:59:42 瀏覽:595
自設計演算法 發布:2025-07-02 16:48:19 瀏覽:785
mac搭建阿里雲伺服器 發布:2025-07-02 16:48:17 瀏覽:443
存儲體的構成 發布:2025-07-02 16:47:41 瀏覽:148
初識java 發布:2025-07-02 16:45:48 瀏覽:409