Skip to content

Repository files navigation

LineMatchingView


🎈 连线题自定义ViewGroup

PlatformLicenseAPIjitpack


Install

Gradle

项目根目录的build.gradle添加如下配置:

allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}

module添加依赖:

dependencies {
implementation "com.github.zaaach:LineMatchingView:x.y"
}

记得把x.y替换为jitpack中的数字

Usage

xml

<com.zaaach.linematchingview.LineMatchingView
android:id="@+id/line_matching_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@color/white"android:padding="8dp"app:lmv_item_width="120dp"app:lmv_item_height="60dp"app:lmv_horizontal_padding="80dp"app:lmv_vertical_padding="16dp"app:lmv_line_width="2dp"app:lmv_line_color_normal="@color/line_normal_color"app:lmv_line_color_correct="@color/correct_color"app:lmv_line_color_error="@color/error_color"/>

java

LineMatchingView<ItemInfo> lineMatchingView;
List<ItemInfo> left = newArrayList<>();
List<ItemInfo> right = newArrayList<>();
lineMatchingView.init(newLineMatchingView.LinkableAdapter<ItemInfo>() {
@OverridepublicViewgetView(ItemInfoitem, ViewGroupparent, intitemType, intposition) {
Viewview = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_text, null);
returnview;
}
@OverridepublicintgetItemType(ItemInfoitem, intposition) {
return0;
}
@OverridepublicvoidonBindView(ItemInfoitem, Viewview, intposition) {
//...
}
@OverridepublicvoidonItemStateChanged(ItemInfoitem, Viewview, intstate, intposition) {
//...
}
@OverridepublicbooleanisCorrect(ItemInfoleft, ItemInforight, intl, intr) {
returnTextUtils.equals(left.desc, right.desc);
}
}).setItems(left, right);

支持的attrs属性

AttributesFormatDescription
lmv_horizontal_paddingdimension|reference两列间距,默认180px
lmv_vertical_paddingdimension|reference垂直方向的间距,默认48px
lmv_item_widthdimension|referenceitem宽度,默认300px
lmv_item_heightdimension|referenceitem高度,默认120px
lmv_line_widthdimension|reference线的宽度,默认6px
lmv_line_color_normalcolor|reference正常颜色,默认Color.GRAY
lmv_line_color_correctcolor|reference正确颜色,默认Color.GREEN
lmv_line_color_errorcolor|reference错误颜色,默认Color.RED

About me

掘金: https://juejin.im/user/56f3dfe8efa6310055ac719f

简书: https://www.jianshu.com/u/913a8bb93d12

淘宝店: LEON家居生活馆 (动漫摆件)

LEON

😉淘宝店求关注😉

License

Copyright (c) 2021 zaaach
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

🔥🔥🔥连线题控件。左右两列连线,支持重连、任意布局、对错展示等特性

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages