अपना बैज बनाओ TextView, जिससे आप कॉल करके अपनी पसंद का संख्यात्मक मान सेट कर सकते हैं setText()। TextViewXML <shape>ड्रॉबल की पृष्ठभूमि सेट करें , जिसके साथ आप एक सीमा के साथ एक ठोस या ढाल सर्कल बना सकते हैं। XML ड्रॉबल दृश्य को फिट करने के लिए स्केल करेगा क्योंकि यह अधिक या कम टेक्स्ट के साथ आकार बदलता है।
रेस / drawable / badge_circle.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#F00" />
<stroke
android:width="2dip"
android:color="#FFF" />
<padding
android:left="5dip"
android:right="5dip"
android:top="5dip"
android:bottom="5dip" />
</shape>
आपको यह देखना होगा कि बड़े 3-4 अंकों की संख्या के साथ अंडाकार / वृत्त कैसे होता है। यदि यह प्रभाव अवांछनीय है, तो नीचे की तरह एक गोल आयत दृष्टिकोण का प्रयास करें। छोटी संख्या के साथ, आयत अभी भी एक सर्कल की तरह दिखेगा, क्योंकि रेडी एक साथ अभिसरण करता है।
रेस / drawable / badge_circle.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="10dip"/>
<solid
android:color="#F00" />
<stroke
android:width="2dip"
android:color="#FFF" />
<padding
android:left="5dip"
android:right="5dip"
android:top="5dip"
android:bottom="5dip" />
</shape>
स्केलेबल पृष्ठभूमि के साथ, आप बस इसे एक की पृष्ठभूमि में जोड़ते हैं TextView, जैसे:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold"
android:background="@drawable/badge_circle"/>
अंत में, इन TextViewबैज को उपयुक्त लेआउट / टैब के शीर्ष पर आपके लेआउट में रखा जा सकता है। मैं संभवत: प्रत्येक बटन को इसके बैज के साथ एक RelativeLayoutकंटेनर में समूहित करके करूंगा , जैसे:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/myButton"
android:layout_width="65dip"
android:layout_height="65dip"/>
<TextView
android:id="@+id/textOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/myButton"
android:layout_alignRight="@id/myButton"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold"
android:background="@drawable/badge_circle"/>
</RelativeLayout>
उम्मीद है कि कम से कम आपको सही दिशा में इंगित करने के लिए पर्याप्त जानकारी है!