GithubHelp home page GithubHelp logo

hexiang1993 / zlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mmlovesyy/zlayout

0.0 1.0 0.0 894 KB

会自动换行的 LinearLayout,当水平方向不足以放置子 View 时,会自动从下一行开始放置。

Java 100.00%

zlayout's Introduction

ZLayout

会自动换行的 LinearLayout,当水平方向不足以放置子 View 时,会自动从下一行开始放置。

自定义属性

  • lineSpacing,行间距;
  • maxLines,显示的最大行数;

使用范例:

<com.mmlovesyy.zlayout.ZLayout xmlns:z="http://schemas.android.com/apk/res/com.mmlovesyy.zlayout"
            android:id="@+id/z"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/background_zlayout"
            z:lineSpacing="40dp"
            z:maxLines="4" />

或者

final ZLayout zLayout = new ZLayout(this);
ViewGroup.LayoutParams zLp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
zLayout.setMaxLines(2);
zLayout.setLineSpacing(200);
zLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_zlayout));

注意

如当子 View 是 TextView 时,请务必确保其为单行。

Demo 演示





todo list:

  • 支持不同高度的子 View;
  • 不支持水平方向的 ScrollView,仍然会换行,而非水平滚动;
  • 设置高度值无效,效果仍等同于 wrap_content;

zlayout's People

Contributors

mmlovesyy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.