美文网首页
Android自定义控件抽屉组件

Android自定义控件抽屉组件

作者: XINHAO_HAN | 来源:发表于2018-03-20 09:08 被阅读0次

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

效果图:

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

相关文章

网友评论

      本文标题:Android自定义控件抽屉组件

      本文链接:https://www.haomeiwen.com/subject/ufjpqftx.html