ANDROID SHAPE畫圓形背景_ANDROID實現角標布局


shape可以繪制矩形環形以及橢圓、所以只需要用橢圓就可以完成需求、在使用的時候將控件比如textview的高寬設置成一樣就是正圓、solid表示遠的填充色、stroke則代表遠的邊框線、所以兩者結合可以實現帶邊緣的圓、Shape 代碼

android 實現角標

<?xml version="1.0" encoding="UTF-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false" >
    <solid android: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" />
    <size android:width="15dp"
          android:height="15dp" />
</shape>

把以上代碼添加到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/design_red_point"
        android:gravity="center"
        android:textSize="@dimen/text_size_comment_20"
        android:text="7"
        android:textColor="@android:color/white" />

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM