鸿蒙开源组件——DividerDrawable

jacksky
发布于 2021-7-21 18:36
浏览
0收藏

This library can help you easily layout and draw dividers on existing views. For better performance, don't create new views for drawing dividers anymore, use drawable instead.

 

该库可以帮助您轻松地在现有视图上布局和绘制分隔线。为了获得更好的性能,请不要再为绘图分隔线创建新视图,而应使用drawable。

Install

Install

添加库的依赖 方式一: 添加har包到lib文件夹内 在entry的gradle内添加如下代码 implementation fileTree(dir: 'libs', include: ['.jar', '.har'])

方式二: allprojects { repositories{ mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:DividerDrawable:1.0.1'

## Usage

Obtain a new `DividerDrawable` instance. And you can set the color and stroke witdh of the divider.
获取一个新的DividerDrawable实例。您可以设置分隔线的颜色和描边样式。

```java
final DividerDrawable dividerDrawable = new DividerDrawable();
dividerDrawable.setStrokeWidth(10)
        .setColor(0xFFFFFFFF)

Similar to the view layout, the DividerDrawable also has a layout that can help draw divider to the relative position of the container(view/drawable/canvas).

 

与视图布局类似,DividerDrawable也具有可帮助将分隔线绘制到容器的相对位置(视图/可绘制/画布)的布局

 

dividerDrawable.getLayout()
        .setOrientation(DividerLayout.ORIENTATION_VERTICAL)
        .setAlign(DividerLayout.ALIGN_PARENT_BOTTOM)
        .setCenter(DividerLayout.CENTER_HORIZONTAL)
        .setMarginBottomDp(20);

 

You can use DividerUtils to easily combine the divider drawable to your existing backgroud drawable.

 

您可以使用DividerUtils轻松地将分隔线可绘制对象与现有的背景图可绘制对象组合。

DividerUtils.addDividersTo(textView, dividerDrawable);

 

openharmony-tpc-DividerDrawable-master.zip 95.62K 22次下载
已于2021-7-21 18:36:44修改
收藏
回复
举报
回复
    相关推荐