I’ve been worrying about my girlfriend lately. When I was preparing a new APP, I was absent-minded. When talking about the calendar, the product said to listen to the technical advice, whether the calendar should be made with the height changing with the content or with the height fixed and the content changing. I have never made a custom calendar, so I don’t know the inside. Then other colleagues said that the height fixed is easier to make, and the result was decided. Result cent task of time, rang rang good do colleague who did not connect, gave me (at that time I thought is to take care of me this small rookie, touched of almost cry a nose), result net searched a circle, elder brother did not have. Height changes good-looking and easy to use, even if it is a fixed height, but also show 6 lines, 4 lines when two lines of gray (5 lines when gray line), at this time I just feel is not everyone elder brother to dig a hole for me, because I heard that simple, to a day of time (then also happy, and can stay for half a day). Ah, I absolutely will not admit that I work overtime, really, this life can not work overtime ah. We’ve been gone a long time, not saying anything. OK, first directly on the product draft and design drawing, have a similar function friends first look at the product draft and design drawing is not similar, if the difference is not big, then the next will help you. The product version

<! <color name="yesterday">#ff222222</color> <! <color name="tomorrow">#ff999999</color> - the current date font color, select - > < color name = "today_select" > # FFF < / color > <! <color name="today_unselected">#ffff6600</color> <! - the color of the circle - > < color name = "round" > # FFFF6600 < / color > <! <color name="month_lunar">#0000</color>Copy the code

Public static final int MONTHLUNAR=5 // Lunar font size

public static final float DOT=4f; Public static final Boolean ROUND_SQUARE=true; Public static final float ROUND=32.0f; Public static final float OFFSET=16f; Public static final float FOUR=50f; Public static final float FIVE=45f; Public static final float SIX=37f; public static final float SIX=37f; // The height of item at 6 linesCopy the code

3, add a small dot to the activity (you can add it after requesting data, you can set it several times, but only the final result is displayed, not superimposed)

protected void initData() { final List<Calendar> schemes = new ArrayList<>(); final int year = mCalendarView.getCurYear(); final int month = mCalendarView.getCurMonth(); Add (getSchemeCalendar(year, month, 3, 0xffD5d5d5, "class ")); Add (getSchemeCalendar(year, month, 6, 0xffD5d5d5, "class ")); Add (getSchemeCalendar(year, month, 9, 0xffD5d5d5, "class ")); mCalendarView.setSchemeDate(schemes); } private Calendar getSchemeCalendar(int year, int month, int day, int color, String text) { Calendar calendar = new Calendar(); calendar.setYear(year); calendar.setMonth(month); calendar.setDay(day); calendar.setSchemeColor(color); Calendar.setscheme (text) is used if the color is marked separately; return calendar; }Copy the code

4. This is pretty much enough (if you need anything else, you’ll have to do it yourself), and you’ll probably be like, “You didn’t tell me how to do it, I’ll kill you.” But I figured you’d beat me to death if I didn’t use the code? So I decided not to say the implementation directly on GitHub address (code is not much, see it yourself) code download address: https://github.com/lpl0129/calendarview 5, is very important Strongly recommend a custom calendar control CalendarView because I reference and USES a lot of program code. https://github.com/huanghaibin-dev/CalendarView and attach a CalendarView introduce how to use the blog https://blog.csdn.net/huanghaibin_dev/article/details/79040147