首页 > 移动平台 > 详细

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

时间:2014-04-14 17:13:44      阅读:776      评论:0      收藏:0      [点我收藏+]

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

 

bubuko.com,布布扣

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

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

原文:http://blog.csdn.net/hcf_force/article/details/23669725

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!