Android自定义蜂窝图实现

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

ZzBeeLayout

A nice Image ViewGroup like honeycomb.

What does it look like ?

Android自定义蜂窝图实现_第1张图片
demo.jpg

How to use it ?

Gradle

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

Maven


  me.zhouzhuo.zzbeelayout
  zz-bee-layout
  1.0.1
  pom

① layout

    

    

属性说明:

属性 说明 类型
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);

  

Permissions

    
    

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

需要写安卓程序的小伙伴请关注我的淘宝店铺:
小周来帮您

你可能感兴趣的:(Android自定义蜂窝图实现)