日历控件开发详解0
从今天开始,我们将一步步学习如何实现一个Android的日历控件,今天是第一天!
一、准备工作之配置参数
制作一个日历控件,我们首先要配置一些参数
1.尺寸
dimension.xml
package com.xys.mycalender.base;import android.app.Activity;import android.graphics.Canvas;import android.graphics.Paint;import android.view.View;import com.xys.mycalender.R;import com.xys.mycalender.interfaces.CalendarElement;/* * 从资源文件中获取该项目的一些公共数据,并使其子类实现onDraw方法 */public class CalendarBase implements CalendarElement{protected Activity activity;protected View view;//画笔protected Paint paint=new Paint();//边距protected float boderMargin;//周名称边距protected float weekNameMargin;//周名称大小protected float weekNameSize;//周末名称颜色protected int weekendColor;public CalendarBase(Activity activity,View view){this.activity=activity;this.view=view;//从资源文件中获取公共数据boderMargin=activity.getResources().getDimension(R.dimen.border_margin);weekNameMargin=activity.getResources().getDimension(R.dimen.weekname_margin);weekNameSize=activity.getResources().getDimension(R.dimen.weekname_size);weekendColor=activity.getResources().getColor(R.color.weekendColor);}public void onDraw(Canvas canvas) {// TODO Auto-generated method stub}}