WrapLayout轻量级换行组件
一款轻轻轻轻量级的自动换行布局,可以设置 Gravity。
懒人使用方法
项目目录——>build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
app——>build.gradle
dependencies {
...
implementation 'com.github.pimaryschoolstudent:WrapLayout:1.0.0'
}
导入成功后像一般的布局使用即可,可以参考项目中的 MainActivity
动态添加组件
var tv = TextView(this)
tv.text = "新添加的TextView"
tv.setBackgroundColor( Color.WHITE)
var lp = ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT,ViewGroup.MarginLayoutParams.WRAP_CONTENT)
wrapLayout.addView(tv,lp)
<!--gravity 设置重心-->
<primary.student.wraplayout.WrapLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gravity="center"
android:id="@+id/wrapLayout"
android:background="@color/colorPrimaryDark">
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:text="1"
android:layout_margin="10dp"
android:background="@color/colorAccent"
android:gravity="center"
/>
</primary.student.wraplayout.WrapLayout>
扩展用法
复制 WrapLayout.java 到你的项目中,在 res/values/attrs.xml
<declare-styleable name="WrapLayout">
<attr name="gravity">
<enum name="center" value="1001"/>
<enum name="left" value="1002"/>
<enum name="right" value="1003"/>
</attr>
</declare-styleable>
然后就可以自由扩展了
评论
WrapLayout轻量级换行组件
一款轻轻轻轻量级的自动换行布局,可以设置Gravity。懒人使用方法项目目录——>build.gradleallprojects{repositories{...maven{url'https:
WrapLayout轻量级换行组件
0
Magic轻量级 UI 组件
Magic是用JavaScript脚本开发的轻量级UI组件,具有性能高效、代码量小、支持多种初始化方式等方面的优势,Web前端开发者可以使用Magic快速搭建前端功能比较复杂的网站。Magic的每个组
Magic轻量级 UI 组件
0
SmallPopCSS 轻量级弹窗组件
SmallPop是一组CSS轻量级弹窗组件。下载引用<link href="spop.css" rel="stylesheet"><!-- Even better, SamallPo
SmallPopCSS 轻量级弹窗组件
0