Drawing number badge like iPhone in Android

前端 未结 3 1217
不知归路
不知归路 2020-12-13 17:09

\"a

I want to draw

3条回答
  •  悲&欢浪女
    2020-12-13 17:28

    Look at my answer here for widgets/app.

    You can use shapecount.xml

    res/layout/tabicon.xml

    
        
                android:layout_margin="0dp"
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content"/>
    
        
    
    
    

    When creating your tab:

    LayoutInflater inflater = LayoutInflater.from(this);
    View view = inflater.inflate(R.layout.tabicon, null);
    final TextView txtCount = (TextView) view.findViewById(R.id.txtCount);
    
    spec = tabHost.newTabSpec("artists").setIndicator(view).setContent(intent);
    

    Now you can use txtCount to update the number in the tab's icon. See the post I pointed out above for an example of TimerTask to test this.

    You will have to arrange the layout as you wish also

提交回复
热议问题