Android 流式布局

2020-07-03 10:46:57 浏览数 (1)

效果:

682657097525172732.jpg

使用方法:
代码语言:javascript复制
<com.aruba.flowlayout.Flowlayout
        android:id="@ id/fl_test"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical">

        <TextView
            android:text="hello" />

        <TextView
            android:text="hello,hi" />

        <TextView
            android:text="你是我的"
            android:textSize="18sp" />

    </com.aruba.flowlayout.Flowlayout>
直接添加到xml布局中,或者代码中使用adapter
代码语言:javascript复制
        Flowlayout flowlayout = findViewById(R.id.fl_test);
        flowlayout.setFlowAdapter(new Flowlayout.FlowAdapter(this){

            @Override
            View getView(int position, LayoutInflater layoutInflater) {
                TextView textView = new TextView(MainActivity.this);
                textView.setText("asdadas");
                textView.setTextSize(10   (new Random().nextInt(6)));
                return textView;
            }

            @Override
            int getCount() {
                return 15;
            }
        });
项目地址:https://gitee.com/aruba/flow_layout.git

0 人点赞