代码拉取完成,页面将自动刷新
项目名称:labeView
所属系列:openharmony的第三方组件适配移植
功能:在按钮 文字 图片上添加角标。
项目移植状态:完成
调用差异:无
开发版本:sdk6,DevEco Studio 2.2 Beta1
基线版本:Release v1.1.2
1.在项目根目录下的build.gradle文件中,
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
}
2.在entry模块的build.gradle文件中,
dependencies {
implementation('com.gitee.chinasoft_ohos:labelview:1.0.0')
......
}
在sdk6,DevEco Studio 2.2 Bate1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
将xml代码放入布局中,如下所示:
LabelButtonView
<com.lid.lib.LabelButtonView
ohos:height="48vp"
ohos:width="200vp"
ohos:background_element="#03a9f4"
ohos:text="Button"
ohos:text_color="#ffffff"
ohos:text_size="14vp"
app:label_backgroundColor="#C2185B"
app:label_distance="50"
app:label_height="70"
app:label_orientation="2"
app:label_text="HD"
app:label_textSize="30"
app:label_textStyle="0"/>
LabelImageView
<com.lid.lib.LabelImageView
ohos:height="280vp"
ohos:width="0vp"
ohos:weight="1"
ohos:background_element="#fff"
ohos:image_src="$media:image1"
ohos:scale_mode="clip_center"
app:label_backgroundColor="#C2185B"
app:label_distance="125"
app:label_orientation="1"
app:label_height="90"
app:label_text="CHINA"
app:label_textSize="40"
app:label_textStyle="2"/>
LabelTextView
<com.lid.lib.LabelTextView
ohos:height="48vp"
ohos:width="100vp"
ohos:background_element="#212121"
ohos:layout_alignment="horizontal_center"
ohos:text="TextView"
ohos:text_size="14vp"
ohos:text_alignment="center"
ohos:text_color="#ffffff"
ohos:top_margin="8vp"
app:label_backgroundColor="#C2185B"
app:label_distance="50"
app:label_orientation="1"
app:label_height="60"
app:label_text="POP"
app:label_textSize="27"
app:label_textStyle="2"/>
如果在自定义视图中需要标签:
1. 创建一个新的视图类扩展' YourView '
2. 使用LabelViewHelper作为你的“成员对象”
3. 在构造函数和onDraw函数中调用LabelViewHelper方法。
4. 在其他函数中调用LabelViewHelper方法
public class LabelXXXView extends YourView implements Component.DrawTask {
LabelViewHelper utils;
public LabelXXXView(Context context) {
this(context, null);
}
public LabelXXXView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public LabelXXXView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
utils = new LabelViewHelper(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
utils.onDraw(canvas, getWidth() - getPaddingLeft() - getPaddingRight(), getHeight() - getPaddingTop() - getPaddingBottom());
}
public void setLabelHeight(int height) {
utils.setLabelHeight(this, height);
}
public int getLabelHeight() {
return utils.getLabelHeight();
}
public void setLabelDistance(int distance) {
utils.setLabelDistance(this, distance);
}
public int getLabelDistance() {
return utils.getLabelDistance();
}
public boolean isLabelVisual() {
return utils.isLabelVisual();
}
public void setLabelVisual(boolean isEnable) {
utils.setLabelVisual(this, isEnable);
}
public int getLabelOrientation() {
return utils.getLabelOrientation();
}
public void setLabelOrientation(int orientation) {
utils.setLabelOrientation(this, orientation);
}
public Color getLabelTextColor() {
return utils.getLabelTextColor();
}
public void setLabelTextColor(Color textColor) {
utils.setLabelTextColor(this, textColor);
}
public Color getLabelBackgroundColor() {
return utils.getLabelBackgroundColor();
}
public void setLabelBackgroundColor(Color backgroundColor) {
utils.setLabelBackgroundColor(this, backgroundColor);
}
public String getLabelText() {
return utils.getLabelText();
}
public void setLabelText(String text) {
utils.setLabelText(this, text);
}
public int getLabelTextSize() {
return utils.getLabelTextSize();
}
public void setLabelTextSize(int textSize) {
utils.setLabelTextSize(this, textSize);
}
public int getLabelTextStyle() {
return utils.getLabelTextStyle();
}
public void setLabelTextStyle(int textStyle) {
utils.setLabelTextStyle(this, textStyle);
}
}
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异# #
Copyright 2014 linger1216
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型