2 Star 2 Fork 0

TS_OHOS / TitleBar

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 4.89 KB
一键复制 编辑 原始数据 按行查看 历史
马圣知 提交于 2022-09-16 08:37 . update README.md.

TitleBar

本项目是基于开源项目TitleBar进行harmonyos化的移植和开发的,可以通过项目标签以及 github地址

移植版本:源master v9.2版本

项目介绍

项目名称:TitleBar

所属系列:harmonyos的第三方组件适配移植

功能:

一个标题栏框架。

项目移植状态:部分移植

不支持功能:
    setLeftTint:设置左图色彩 --》 ohos暂不支持setColorFilter方法,无法实现该效果
    setRightTint:设置右图色彩 --》 ohos暂不支持setColorFilter方法,无法实现该效果
demo未显示效果:
    折叠效果未显示,此效果未demo中使用com.google.android.material.appbar.AppBarLayout 
        + com.google.android.material.appbar.CollapsingToolbarLayout实现,ohos中无对应的组件,
        同时该功能并非移植的组件的功能。

调用差异:基本没有使用差异,请参照demo使用

原项目Doc地址:https://github.com/getActivity/TitleBar

编程语言:java

项目截图(涉及文件仅供demo测试使用)

demo运行效果 demo运行效果 运行效果

安装教程

方案一

可以先下载项目,将项目中的library库提取出来放在所需项目中通过build配置

dependencies {
     implementation project(":library")
}

方案二

  • 1.项目根目录的build.gradle中的repositories添加:
    buildscript {
       repositories {
           ...
           mavenCentral()
       }
       ...
   }
   
   allprojects {
       repositories {
           ...
           mavenCentral()
       }
   }
  • 2.开发者在自己的项目中添加依赖
dependencies {
    implementation 'com.gitee.ts_ohos:titlebar:1.0.0'
}

How to use

<com.hjq.bar.TitleBar
    ohos:id="$+id:tb_main_bar"
    ohos:height="60vp"
    ohos:width="match_parent"
    ohos:top_margin="20vp"
    ohos:padding="5vp"
    app:leftIcon="$media:ic_launcher"
    app:leftTitle="左边"
    app:rightIcon="$media:ic_launcher"
    app:rightTitle="右边"
    app:title="监听标题栏点击事件"/>

监听点击事件: TitleBar titleBar = (TitleBar) findComponentById(ResourceTable.Id_tb_main_bar); titleBar.setOnTitleBarListener(new OnTitleBarListener() { @Override public void onLeftClick(Component view) { new ToastDialog(getContext()).setText("左项 View 被点击").show(); }

      @Override
      public void onTitleClick(Component view) {
        new ToastDialog(getContext()).setText("中间 View 被点击").show();
      }

      @Override
      public void onRightClick(Component view) {
        new ToastDialog(getContext()).setText("右项 View 被点击").show();
      }
    });

你还可以为标题栏定义自己的样式,指定属性 barStyle:

<com.hjq.bar.TitleBar
    ohos:height="50vp"
    ohos:width="match_parent"
    ohos:top_margin="20vp"
    app:barStyle="night"
    app:leftTitle="返回"
    app:rightTitle="设置"
    app:title="夜间模式的标题栏"/>

自定布局:

<com.hjq.bar.TitleBar
    ohos:height="50vp"
    ohos:width="match_content"
    ohos:top_margin="20vp"
    app:title="自定义标题栏">

    <DirectionalLayout
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:alignment="end|vertical_center"
        ohos:layout_alignment="end|vertical_center"
        ohos:orientation="horizontal">

        <Image
            ohos:height="40vp"
            ohos:width="40vp"
            ohos:image_src="$media:ic_launcher"/>

        <Image
            ohos:height="40vp"
            ohos:width="40vp"
            ohos:end_margin="10vp"
            ohos:image_src="$media:ic_launcher"
            ohos:start_margin="5vp"/>

    </DirectionalLayout>

</com.hjq.bar.TitleBar>

跑马灯效果:

<com.hjq.bar.TitleBar
    ohos:height="50vp"
    ohos:width="match_parent"
    ohos:top_margin="20vp"
    app:lineVisible="false"
    app:pmdText="true"
    app:title="标题开启跑马灯效果,就问你溜不溜"/>

License

Copyright 2018 Huang JinQun

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.

Java
1
https://gitee.com/ts_ohos/TitleBar.git
git@gitee.com:ts_ohos/TitleBar.git
ts_ohos
TitleBar
TitleBar
master

搜索帮助