Android自定义控件抽屉组件

一种抽屉式的ListView动画,基本原理是通过ListView集成的

效果图:

5337239-32932856234d1e9f.gif
1521507576187mzlist.gif

基本思路:使用LayoutParams改变大小

详情请看:https://www.jianshu.com/p/77a4ab643b8b

代码使用方法:

    xhList = findViewById(R.id.xhList);

        for (int i = 0; i < 50; i++) {
            arrayList.add(i + "");
        }

        xhList.setXHAdapter(new XHBaseAdapter<String>(arrayList) {
            @Override
            public XHViewHolder getXHViewHolder() {
                View inflate = View.inflate(MainActivity.this, R.layout.test_2, null);
                xhLineChar = inflate.findViewById(R.id.xhchar);
                xhLineChar.setMaxTable(10.5f);
                xhLineChar.setMinTable(-8.5f);

                ArrayList<XHData> xhData = new ArrayList<>();

        /*xhData.add(new XHData(20,0));
        xhData.add(new XHData(50,80));
        xhData.add(new XHData(60,30));
        xhData.add(new XHData(80,26));
        xhData.add(new XHData(17,26));
        xhData.add(new XHData(80,65));
        xhData.add(new XHData(26,74));
        xhData.add(new XHData(20,86));*/


                xhData.add(new XHData(true,5.6f,"2018/12-12"));
                xhData.add(new XHData(true,9.5f,"2018/12-12"));
                xhData.add(new XHData(true,8.5f,"2018/12-12"));
                xhData.add(new XHData(true,10.5f,"2018/12-12"));
                xhData.add(new XHData(true,7.5f,"2018/12-12"));
                xhData.add(new XHData(true,6.5f,"2018/12-12"));
                xhData.add(new XHData(true,-6.5f,"2018/12-12/15"));
                xhData.add(new XHData(true,5.6f,"2018/12-12"));
                xhData.add(new XHData(true,9.5f,"2018/12-12"));
                xhData.add(new XHData(true,8.5f,"2018/12-12"));
                xhData.add(new XHData(true,10.5f,"2018/12-12"));
                xhData.add(new XHData(true,7.5f,"2018/12-12"));
                xhData.add(new XHData(true,6.5f,"2018/12-12"));
                xhData.add(new XHData(true,-6.5f,"2018/12-12/15"));
                xhData.add(new XHData(true,5.6f,"2018/12-12"));
                xhData.add(new XHData(true,9.5f,"2018/12-12"));
                xhData.add(new XHData(true,8.5f,"2018/12-12"));
                xhData.add(new XHData(true,10.5f,"2018/12-12"));
                xhData.add(new XHData(true,7.5f,"2018/12-12"));
                xhData.add(new XHData(true,6.5f,"2018/12-12"));
                xhData.add(new XHData(true,-6.5f,"2018/12-12/15"));
                xhLineChar.setLineHOrLineW(2.0f,10.0f);
                xhLineChar.setDataArray(xhData);
                return new MyXhViewHolder(View.inflate(MainActivity.this,R.layout.test_layout,null)/*第一个View*/,inflate/*第二个View*/);
            }

            @Override
            public void initView(int position, XHViewHolder xhViewHolder, String o) {

                MyXhViewHolder myXhViewHolder = (MyXhViewHolder) xhViewHolder;
                myXhViewHolder.textView.setText(o);

            }
        });
    }

    class MyXhViewHolder extends XHViewHolder{


        public TextView textView;
        public MyXhViewHolder(View view,View view2) {
            super(view,view2);
            textView = (TextView) findViewById(R.id.textView);
        }
    }

github:https://github.com/hanxinhao000/ListViewAnim

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值