Add a digital reminder to the top right corner of the Android icon

Source: Internet
Author: User

Method One:UseOpen Source Project Viewbadger,address on GitHub:https://github.com/jgilfelt/android-viewbadger Effect:
[Java]View Plaincopy
    1. <textview
    2. android:id="@+id/tv1"
    3. Android:layout_width="wrap_content"
    4. android:layout_height="wrap_content"
    5. android:padding="15DP"
    6. android:text="Text 1" />
[Java]View Plaincopy
    1. <span style= "Font-family:arial, Helvetica, Sans-serif;" ></span>
[Java]View Plaincopy
  1. TV = (TextView) Findviewbyid (R.ID.TV1);
  2. Badgeview Badgeview = new Badgeview (mainactivity. This  , TV); //instantiation of Badgeview
  3. Badgeview.settext ("a");
  4. //Badgeview.settextsize (8.5f); Set the size of text
  5. Badgeview.setbadgeposition (Badgeview.position_top_right); //set in the upper right corner   
  6. Badgeview.settextcolor (Color.dkgray); //font setting color   
  7. 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
  1. <framelayout
  2. android:id="@+id/framelayout1"
  3. Android:layout_width="wrap_content"
  4. android:layout_height="wrap_content" >
  5. <textview
  6. android:id="@+id/textview1"
  7. Android:layout_width="wrap_content"
  8. android:layout_height="wrap_content"
  9. android:padding="10DP"
  10. android:text="Text 2" />
  11. <textview
  12. Android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:layout_gravity="Top|right"
  15. android:background="#FF0000"
  16. android:text="All"
  17. Android:textcolor="@android: Color/white" />
  18. </FrameLayout>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.