【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