VS MONO Android开发控件悬浮显示提醒 自定义背景颜色、字体、数字颜色、摆放位置

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开发控件悬浮显示提醒 自定义背景颜色、字体、数字颜色、摆放位置,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。