Method One:UseOpen Source Project Viewbadger,address on GitHub:https://github.com/jgilfelt/android-viewbadger Effect:
[Java]View Plaincopy
- <textview
- android:id="@+id/tv1"
- Android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="15DP"
- android:text="Text 1" />
[Java]View Plaincopy
- <span style= "Font-family:arial, Helvetica, Sans-serif;" ></span>
[Java]View Plaincopy
- TV = (TextView) Findviewbyid (R.ID.TV1);
- Badgeview Badgeview = new Badgeview (mainactivity. This , TV); //instantiation of Badgeview
- Badgeview.settext ("a");
- //Badgeview.settextsize (8.5f); Set the size of text
- Badgeview.setbadgeposition (Badgeview.position_top_right); //set in the upper right corner
- Badgeview.settextcolor (Color.dkgray); //font setting color
- Badgeview.show (); //Display
[Java]View Plaincopy
This achieves the above effect, note the referenceOpen Source Project Viewbadger, in the same folder as the new project file, or it will be wrongmethod Two: using frame structure layout framelayout Effect:the layout is as follows: This will do.
[Java]View Plaincopy
- <framelayout
- android:id="@+id/framelayout1"
- Android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- <textview
- android:id="@+id/textview1"
- Android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="10DP"
- android:text="Text 2" />
- <textview
- Android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="Top|right"
- android:background="#FF0000"
- android:text="All"
- Android:textcolor="@android: Color/white" />
- </FrameLayout>