Android實現右上角的紅色小圓球提示氣泡

cm54 9年前發布 | 81K 次閱讀 Android Android開發 移動開發

效果圖:


可以重寫View的onDraw完成該功能,也可以寫布局文件完成該功能。現在使用布局文件完成。暫時先簡單寫一個TextView右上角的提示小紅球,也可以根據需要寫一個ImageView右上角的小紅球提示。


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:padding="2dip"
        android:layout_width="match_parent"
        android:layout_height="50dip"

        android:gravity="center"
        android:text="01234567890abcdefghijklmnopqrstuvwxyz!" />

    <FrameLayout 
        android:padding="1dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:layout_width="20dip"
            android:layout_height="20dip"
            android:layout_gravity="right"
            android:background="@drawable/tips_textview_bg"
            android:gravity="center"
            android:text="9"
            android:textSize="15dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" />
    </FrameLayout>

</FrameLayout>


依賴的tips_textview_bg.xml文件


<?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= "#FF0000" />

</shape>




 本文由用戶 cm54 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!