代码拉取完成,页面将自动刷新
本项目是基于开源项目MaterialIntroView进行ohos化的移植和开发的,可以通过项目标签以及github地址 ( https://github.com/iammert/MaterialIntroView )追踪到原项目版本
方案一
dependencies {
implementation fileTree(dir: 'libs', include: ['*.har'])
……
}
方案二
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
dependencies {
implementation 'co.mobiwise.ohos:materialintro:1.0.1'
}
1.创建动画实例,根据需求可自行扩展
public static void performAnimation(Component component) {
createAnimator animatorX = new createAnimator(component);
createAnimator animatorY = new createAnimator(component);
/**
* 设置component 监听,更新UI,必须设置
*/
component.setBindStateChangedListener(new Component.BindStateChangedListener() {
@Override
public void onComponentBoundToWindow(Component component) {
animatorX.scaleX();
animatorY.scaleY();
}
@Override
public void onComponentUnboundFromWindow(Component component) {
animatorX.stop();
animatorY.stop();
}
});
}
private static class createAnimator {
private final AnimatorProperty animatorProperty;
private final float width;
private final float height;
public createAnimator(Component component) {
/**
* 获取当前component宽和高
*/
width = component.getWidth();
height = component.getHeight();
/**
* 创建属性动画实例
*/
animatorProperty = new AnimatorProperty(component);
/**
* 设置透明度
*/
// animatorProperty.alphaFrom(component.getPivotX()).alpha(0.9f);
/**
* 设置循环播放次数
*/
animatorProperty.setLoopedCount(Animator.INFINITE);
/**
* 设置动画变化类型:匀速变化 Animator.CurveType.LINEAR 4
*/
animatorProperty.setCurveType(Animator.CurveType.SMOOTH_STEP);
/**
* 设置持续时间
*/
animatorProperty.setDuration(1000);
}
public void scaleX() {
animatorProperty.scaleX(0.6f);
animatorProperty.start();
}
public void scaleY() {
animatorProperty.scaleY(0.6f);
animatorProperty.start();
}
public void stop() {
animatorProperty.stop();
}
}
2.设置组件透明度
/**
* 设置透明度
*/
public static void createAlpha(Component component, int alpha) {
ShapeElement shapeElement = new ShapeElement();
shapeElement.setShape(OVAL);
shapeElement.setAlpha(alpha);
component.setBackground(shapeElement);
}
3.设置圆角
/**
* 设置不同的圆角
*/
public static Component createRadius(Component component, Context context) {
ShapeElement shapeElement = new ShapeElement();
shapeElement.setShape(ShapeElement.RECTANGLE);
shapeElement.setCornerRadius(10f);
shapeElement.setCornerRadiiArray(new float[]{20, 40, 30, 60, 20, 20, 100, 120});
component.setBackground(shapeElement);
return component;
}
4.设置shape圆
public static Component createCircular(Component component, Context context, RgbColor rgbColor, int width, int height) {
component.setWidth(width);
component.setHeight(height);
ShapeElement shapeElement = new ShapeElement();
shapeElement.setShape(OVAL);
shapeElement.setRgbColor(rgbColor);
component.setBackground(shapeElement);
return component;
}
版本迭代 V1.0.1
Copyright 2015 Mert Şimşek.
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。