axml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/button1" android:text="button1" /> </LinearLayout>
Activity1.cs
using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Graphics; using Android.Util; namespace myBadge{ [Activity(Label = "myBadge", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : Activity { View target; BadgeView badge; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); target = FindViewById<View>(Resource.Id.button1); Button btn = FindViewById<Button>(Resource.Id.button1); btn.Click += btn_Click; badge = new BadgeView(this,(IAttributeSet)null,Android.Resource.Attribute.TextViewStyle, target); badge.Text = "10"; badge.setBadgePosition(BadgeView.POSITION_BOTTOM_RIGHT); badge.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Normal); badge.SetTextColor(Color.White); badge.setBadgeBackgroundColor(Color.Red); badge.toggle(); } void btn_Click(object sender, EventArgs e) { badge.hide(); } } }
重写BadgeView 类
http://download.csdn.net/detail/hcf_force/7190449
VS MONO Android开发控件悬浮显示提醒 自定义背景颜色、字体、数字颜色、摆放位置,布布扣,bubuko.com