鸿蒙开源组件——轻量级消息显示库
头像 Q 2022-02-19 16:45:14    发布
1783 浏览 10 点赞 19 收藏

Cookie

CookieBar是一个轻量级的库,用于在屏幕顶部或底部显示简短的消息。

方案一


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

方案二


implementation project(':library')

方案三


implementation 'io.openharmony.tpc.thirdlib:CookieBar:1.0.2'

简单使用CookieBar.


 new CookieBar.Builder(MainActivity.this)
                        .setTitle("TITLE")
                        .setMessage("MESSAGE")
                        .show();

带图标和按钮的CookieBar使用


 new CookieBar.Builder(MainActivity.this)
                        .setTitle("TITLE")
                        .setIcon(R.mipmap.ic_launcher)
                        .setMessage("MESSAGE")
                        .setAction("ACTION", new OnActionClickListener() {
                            @Override
                            public void onClick() {
                            }
                        })
                        .show();

您可以通过设置主题的属性来更改默认样式


{
  "color":[
    {
      "name":"default_bg_color",
      "value":"#BDBDBD"
    },
    {
      "name":"default_title_color",
      "value":"#ffffff"
    },
    {
      "name":"default_message_color",
      "value":"#ffffff"
    },
    {
      "name":"white",
      "value":"#ffffff"
    },
    {
      "name":"default_action_color",
      "value":"#26a69a"
    }
  ]
}

或者使用cookie生成器动态更改样式。

  • layoutGravity
  • backgroundColor
  • titleColor
  • messageColor
  • actionColor
  • duration

New Features

1.0.0

  • 操作按钮可以替换为图标。

License


Copyright 2017 Eric Liu

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.


©本站发布的所有内容,包括但不限于文字、图片、音频、视频、图表、标志、标识、广告、商标、商号、域名、软件、程序等,除特别标明外,均来源于网络或用户投稿,版权归原作者或原出处所有。我们致力于保护原作者版权,若涉及版权问题,请及时联系我们进行处理。
分类
其它
头像

Q

我还没有写个人简介......

85

帖子

0

提问

245

粉丝

关注
最新发布
热门推荐
地址:北京市朝阳区北三环东路三元桥曙光西里甲1号第三置业A座1508室 商务内容合作QQ:2291221 电话:13391790444或(010)62178877
版权所有:电脑商情信息服务集团 北京赢邦策略咨询有限责任公司
声明:本媒体部分图片、文章来源于网络,版权归原作者所有,我司致力于保护作者版权,如有侵权,请与我司联系删除

京ICP备:2022009079号-2

京公网安备:11010502051901号

ICP证:京B2-20230255