2015-06-04 45 views
2

我想在我的按钮中添加徽章,我该怎么做?Android如何将徽章添加到按钮

enter image description here

按钮:

    <Button 
        android:id="@+id/button" 
        android:layout_width="0dp" 
        android:layout_weight="1" 
        android:background="@drawable/badge_circle" 
        android:gravity="center" 
        android:padding="12dip" 
        android:text="Button" 
        android:textColor="#ffffff"/> 
+1

检查这个http://stackoverflow.com/questions/6011786/add-new-item-算到图标上的按钮,机器人 – Umair

回答

1

需要设置按钮的化合物可绘制。 请看thisthis以便更好地了解。 如果你还有其他问题。问。

1

使用由图书馆提供的这个library

样品例如

View target = findViewById(R.id.target_view); 
BadgeView badge = new BadgeView(this, target); 
badge.setText("1"); 
badge.show(); 

还要检查这个Question

相关问题