【1】布局文件html
1.RelativeLayout布局android
2.TextView设置backgroundapp
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_gv_item_selector" > <LinearLayout android:id="@+id/logo_show_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:background="@drawable/bg_gv_item_selector" android:gravity="center" android:orientation="vertical" > <com.zte.moa.view.RoundImageView android:id="@+id/lv_appicon_imageview" android:layout_width="@dimen/dp_60" android:layout_height="@dimen/dp_60" android:contentDescription="@null" android:src="@drawable/icon_app_default" /> <TextView android:id="@+id/lv_appname_textview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_10" android:gravity="center" android:paddingBottom="@dimen/dp_3" android:text="@string/str_icon_b2c" android:textColor="@color/black" android:textSize="@dimen/sp_14" /> </LinearLayout> <!--数字角标在此!!!--> <TextView android:id="@+id/msg_show_dot_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/logo_show_view" android:layout_marginRight="10dp" android:layout_marginTop="8dp" android:background="@drawable/bg_msg_counter_show" android:gravity="center" android:singleLine="true" android:textStyle="bold" android:text="00" android:textColor="@color/white" android:textSize="@dimen/sp_12" android:visibility="invisible" /> </RelativeLayout>
【2】原理工具
使用相对布局,设定好角标的位置布局
动手制做.9.png图片<将一张标准圆变成可拉伸的PNG图片>code
显示1~9的时候不须要拉升xml
显示10~99+的时候Android会自动拉伸图片htm
【3】.9.png图片制做图片
工具:E:\01.Tools\sdk\tools\draw9patch.batip
编辑要点:
将一张图片分为:上、下、左、右 可编辑的部分【自行脑补】
注意点1:上、左必定要有拉伸区域,且仅仅用来做为拉伸
注意点2:下、右 主要是你要显示的文本内容的,且仅仅控制内容
注意点3:当填充的内容超过黑线的长度,那么上、左黑线部分将会被拉伸
【4】图片
【5】参考网址
http://jingyan.baidu.com/article/915fc414c9f7ef51384b206f.html