Android自定义水平时历控件

ZzHorizontalCalenderView

A horizontal and scrollable CalenderView.

Github地址:https://github.com/zhouzhuo810/ZzHorizontalCalenderView

Gradle:

compile 'me.zhouzhuo.zzhorizontalcalenderview:zz-horizontal-calenderview:1.0.1'

Maven:

<dependency>
  <groupId>me.zhouzhuo.zzhorizontalcalenderview</groupId>
  <artifactId>zz-horizontal-calenderview</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

职能图如下:

zzhorizontalcalenderview.gif

列github托管地址:https://github.com/zhouzhuo810/ZzBeeLayout

功能简介:

1.援助年、月、日、星期的文字颜色配置;
2.支撑日之当选颜色配置;
3.支撑时对话框选拔;
4.支撑年与月点击回调;
5.支撑年月日礼拜点击回调;
6.匡助选中自动滑动到中间;
7.辅助今日有点圆点标注;
8.支撑先天多少圆点颜色配置;
9.富有配置都补助xml属性配置或者java代码动态设置;
10.出最小载配置;

属性

    <declare-styleable name="ZzHorizontalCalenderView">
        <attr name="zhc_show_pick_dialog" format="boolean" />
        <attr name="zhc_min_year" format="integer" />
        <attr name="zhc_unit_color" format="color|reference" />
        <attr name="zhc_selection_color" format="color|reference" />
        <attr name="zhc_press_shape_selector" format="reference" />
        <attr name="zhc_year_text_color" format="color|reference" />
        <attr name="zhc_month_text_color" format="color|reference" />
        <attr name="zhc_week_text_color" format="color|reference" />
        <attr name="zhc_day_selected_text_color" format="color|reference" />
        <attr name="zhc_day_unselected_text_color" format="color|reference" />
        <attr name="zhc_today_point_color" format="color|reference" />
    </declare-styleable>

ZzBeeLayout

A nice Image ViewGroup like honeycomb.

<h2>What does it look like ?</h2>

图片 1

demo.jpg

<h2>How to use it ?</h2>

Gradle

compile 'me.zhouzhuo.zzbeelayout:zz-bee-layout:1.0.1'

Maven

<dependency>
  <groupId>me.zhouzhuo.zzbeelayout</groupId>
  <artifactId>zz-bee-layout</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

① layout

    <me.zhouzhuo.zzbeelayout.ZzBeeLayout
        android:id="@+id/bee"
        android:layout_centerInParent="true"
        android:layout_width="300dp"
        android:layout_height="300dp"
        app:zz_def_res="@mipmap/ic_launcher"
        app:zz_child_size="100dp">

    </me.zhouzhuo.zzbeelayout.ZzBeeLayout>

属性表达:

属性 说明 类型
zz_def_res 默认加载中图片或颜色 图片或颜色资源id
zz_child_size 每张图片默认宽度 尺寸(dp)

② java

        ZzBeeLayout zzBeeLayout = (ZzBeeLayout) findViewById(R.id.bee);

        //from http url
        zzBeeLayout.setImageUrls(new String[]{
                "http://img0.imgtn.bdimg.com/it/u=3273293410,2667810732&fm=11&gp=0.jpg",
                "http://img0.imgtn.bdimg.com/it/u=3271149477,3744926107&fm=11&gp=0.jpg",
                "http://img4.imgtn.bdimg.com/it/u=4186654312,3515491732&fm=23&gp=0.jpg",
                "http://img2.imgtn.bdimg.com/it/u=1192715945,443541801&fm=21&gp=0.jpg",
                "http://img3.imgtn.bdimg.com/it/u=2016448457,3556493612&fm=23&gp=0.jpg",
                "http://img0.imgtn.bdimg.com/it/u=2155062783,607707723&fm=23&gp=0.jpg",
                "http://img5.imgtn.bdimg.com/it/u=2404996392,2561119365&fm=23&gp=0.jpg"
        });

/*
        //from drawable res
        zzBeeLayout.setImageRes(new int[] {
                R.drawable.one,
                R.drawable.two,
                R.drawable.three,
                R.drawable.four,
                R.drawable.five,
                R.drawable.six,
                R.drawable.seven
        });*/

        //from file Uri
        //zzBeeLayout.setImageUris(Uri[] urIs)

        //from file Path
        //zzBeeLayout.setImageFilePath(String[] imageFilePath)


        //set click listener
        zzBeeLayout.setOnImageClickListener(new ZzBeeLayout.OnImageClickListener() {
            @Override
            public void onImageClick(SvgImageView iv, int position) {
                Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();
            }
        });

        //resize if necessary
        zzBeeLayout.getLayoutParams().width = 900;
        zzBeeLayout.getLayoutParams().height = 900;
        zzBeeLayout.setChildSize(300);

<h2>Permissions</h2>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

玩安卓版王者荣耀的情侣,刷金币看这里
链接:http://pan.baidu.com/s/1gfKIeh9
辅助群:171977523

需写安卓程序的同伴请关注我之Taobao店铺:
小周来协理你

属性表明:

属性名称 属性作用 属性类型
zhc_show_pick_dialog 点击年或月是否弹出日期选择对话框 boolean
zhc_unit_color 年月单位的颜色 color
zhc_min_year 可选的最小年份 integer
zhc_selection_color 日的选中颜色 color
zhc_press_shape_selector 年或月或日点击效果选择器 selector
zhc_year_text_color 年的颜色 color
zhc_month_text_color 月的颜色 color
zhc_week_text_color 星期的颜色 color
zhc_day_selected_text_color 日选中时文字颜色 color
zhc_day_unselected_text_color 日未选中时文字颜色 color
zhc_today_point_color 今天的下表点的颜色 color

因此法简介:

① xml 代码

    <me.zhouzhuo.zzhorizontalcalenderview.ZzHorizontalCalenderView
        android:id="@+id/zz_horizontal_calender_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:zhc_day_selected_text_color="@android:color/white"/>

②java 代码

 final ZzHorizontalCalenderView view = (ZzHorizontalCalenderView) findViewById(R.id.zz_horizontal_calender_view);
    //日点击监听
    view.setOnDaySelectedListener(new ZzHorizontalCalenderView.OnDaySelectedListener() {
        @Override
        public void onSelected(boolean hasChanged, int year, int month, int day, int week) {
            tvResult.setText("日期是否有变化:" + hasChanged + ",\n\n日期:" + year + "-" + month + "-" + day + ",\n\n星期:" + week);
        }
    });

    //动态设置各种属性值:
    view.setShowPickDialog(true);
    view.setUnitColorResId(android.R.color.holo_green_dark);
    view.setDayTextColorSelectedResId(android.R.color.holo_blue_bright);
    view.setDayTextColorNormalResId(android.R.color.holo_red_dark);
    view.setDaySelectionColorResId(android.R.color.holo_orange_dark);
    view.setTodayPointColor(Color.YELLOW);
    view.setMonthTextColor(Color.RED);
    view.setYearTextColor(Color.BLUE);

    //年月点击监听
    view.setOnYearMonthClickListener(new ZzHorizontalCalenderView.OnYearMonthClickListener() {
        @Override
        public void onYearClick(int selectedYear, int selectedMonth) {
            tvResult.setText("点击了年:("+selectedYear+","+selectedMonth+")");
        }

        @Override
        public void onMonthClick(int selectedYear, int selectedMonth) {
            tvResult.setText("点击了月 :("+selectedYear+","+selectedMonth+")");
        }
    });

玩安卓版王者荣耀的情侣,刷金币看这里
链接:http://pan.baidu.com/s/1gfKIeh9
辅助群:171977523

内需写安卓程序的伙伴请关注我的天猫店铺:
小周来扶持您

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website