我写了一个软件可以收发短信,但是收到短信未读短信时,想在我的软件的图标右上角添加数字。现在可以实现在Activity 内的控件上添加数字,但如何在软件图标的右上角添加数字,苦思冥想不得其法,故在此跪求各路大神指点迷境,如有代码范例感激不尽。。。。
更多
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas./apk/res/android" android:layout_width="match_parent" android:layout_height="45dp" android:background="@drawable/good_list_bg" android:orientation="horizontal" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/foot_bg" android:gravity="center" > <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.25" > <ImageView android:id="@+id/toolbar_tabonebg" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/footer_active_bg" android:visibility="visible" /> <ImageView android:id="@+id/toolbar_tabone" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:background="#00000000" android:padding="7dp" android:src="@drawable/footer_home_icon" /> </FrameLayout> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.25" > <ImageView android:id="@+id/toolbar_tabtwobg" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/footer_active_bg" android:visibility="invisible" /> <ImageView android:id="@+id/toolbar_tabtwo" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:background="#00000000" android:padding="7dp" android:src="@drawable/footer_search_icon" /> </FrameLayout> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.25" > <ImageView android:id="@+id/toolbar_tabthreebg" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/footer_active_bg" android:visibility="invisible" /> <ImageView android:id="@+id/toolbar_tabthree" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:background="#00000000" android:padding="7dp" android:src="@drawable/footer_shopping_cart_icon" /> <LinearLayout android:id="@+id/shopping_cart_num_bg" android:layout_width="15dp" android:layout_height="15dp" android:layout_gravity="center_horizontal" android:layout_marginLeft="15dp" android:layout_marginTop="3dp" android:background="@drawable/search_new_shopping_cart_num_bg" android:gravity="center" android:orientation="vertical" > <TextView android:id="@+id/shopping_cart_num" android:layout_width="15dp" android:layout_height="15dp" android:layout_marginBottom="2dp" android:gravity="center" android:text="0" android:textColor="#ffffff" android:textSize="10dp" /> </LinearLayout> </FrameLayout> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.25" > <ImageView android:id="@+id/toolbar_tabfourbg" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/footer_active_bg" android:visibility="invisible" /> <ImageView android:id="@+id/toolbar_tabfour" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:background="#00000000" android:padding="7dp" android:src="@drawable/footer_user_icon" /> </FrameLayout> </LinearLayout> </LinearLayout>
这种github上有开源的,别人封装好了。https://github.com/jgilfelt/android-viewbadger各种齐全的效果。
噢,mark一下,以后用到,,,
楼主想要这样的效果! 望大神指教,mark一下
我知道楼主是想在桌面上实现应用icon上的数字,要是应用内就简单了,也不会来问了。 我觉得这个在安卓上没法实现,只有系统自带的才有。要不然,微信这种在ios上实现了这种效果,为何android上没有 好厉害 这个是系统功能,同一个软件在miui上有这样的提示,在原生安卓上没有 还是哥们了解我 那给个方法噻 因为这个应用商店是 小米的,所以它可以显示
http://www.eoe/thread-191571-1-1.html 可以参考这个,将浮动插件浮动到icon右上角的位置。
android的应该不太好实现吧!否则ios上那么流行,android不可能不拿过来用的!
按经验做个假设哈,记得经常在开机时候读SD卡没那么快,图标都是没有的,一段时间后就出现了,这个图标控制是动态的,而且大概就在安装的目录下维护的,写个sevice来修改该图标试试?在window开发下,桌面图标毫无疑问,只是一个快捷方式,而且图片还是可以修改的,相对这个也是类似的吧。。
我觉得程序就是为了破坏系统而存在的,不要被限制了
|
|