引导页面的移动箭头效果 guide arrow animation

2024-03-02 09:48

本文主要是介绍引导页面的移动箭头效果 guide arrow animation,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

要实现类似效果


由于动画是非平滑的,所以不能用平移的方式来实现,这里就定时去更新在父布局的位置来是实现

先看布局代码

<RelativeLayoutandroid:id="@+id/swipe_layout"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom|right"android:layout_marginBottom="10dip" android:layout_marginRight="10dip"><RelativeLayoutandroid:id="@+id/guide_arrow"android:layout_width="wrap_content"android:layout_alignParentRight="true"android:layout_height="20dip" ><ImageViewandroid:id="@+id/guide_arrow_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:src="@drawable/guide_arrow" /><ImageViewandroid:id="@+id/guide_arrow_2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/guide_arrow_1"android:alpha="0.7"android:src="@drawable/guide_arrow" /><ImageViewandroid:id="@+id/guide_arrow_3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/guide_arrow_2"android:alpha="0.3"android:src="@drawable/guide_arrow" /></RelativeLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/guide_arrow"android:layout_alignParentRight="true"android:layout_marginTop="5dip"android:textSize="12sp"android:textColor="@color/white"android:text="@string/swipe_up" /></RelativeLayout>
实现代码:

@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.new_guide);swipeView = findViewById(R.id.swipe_layout);iv1 = (ImageView) findViewById(R.id.guide_arrow_1);iv2 = (ImageView) findViewById(R.id.guide_arrow_2);iv3 = (ImageView) findViewById(R.id.guide_arrow_3);iv1.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {// TODO Auto-generated method stubiv1Left = iv1.getLeft();iv1Height = iv1.getHeight();iv1Right = iv1.getRight();iv1Top = iv1.getTop();iv1Temp = iv1Top;iv1.getViewTreeObserver().removeGlobalOnLayoutListener(this);handler.post(arrowRunable);}});}class ArrowRunable implements Runnable {@Overridepublic void run() {// TODO Auto-generated method stubiv1.layout(iv1Left, iv1Temp - iv1Height-1, iv1Right, iv1Temp-1);iv2.layout(iv1Left, iv1Temp, iv1Right, iv1Temp + iv1Height);iv3.layout(iv1Left, iv1Temp + iv1Height+1, iv1Right, iv1Temp + 2*iv1Height+1);iv1Temp -= iv1Height;if (iv1Temp + 3 * iv1Height < 0) {iv1Temp = iv1Top;}handler.postDelayed(this, 180);}}@Overrideprotected void onDestroy() {// TODO Auto-generated method stubsuper.onDestroy();if (handler != null && arrowRunable != null) {Logger.d("removeCallbacks");handler.removeCallbacks(arrowRunable);}}
ok,这样应该就可以了,大家有更好的,欢迎交流


这篇关于引导页面的移动箭头效果 guide arrow animation的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/765718

相关文章

SpringBoot全局异常拦截与自定义错误页面实现过程解读

《SpringBoot全局异常拦截与自定义错误页面实现过程解读》本文介绍了SpringBoot中全局异常拦截与自定义错误页面的实现方法,包括异常的分类、SpringBoot默认异常处理机制、全局异常拦... 目录一、引言二、Spring Boot异常处理基础2.1 异常的分类2.2 Spring Boot默

C++ 右值引用(rvalue references)与移动语义(move semantics)深度解析

《C++右值引用(rvaluereferences)与移动语义(movesemantics)深度解析》文章主要介绍了C++右值引用和移动语义的设计动机、基本概念、实现方式以及在实际编程中的应用,... 目录一、右值引用(rvalue references)与移动语义(move semantics)设计动机1

Python结合Free Spire.PDF for Python实现PDF页面旋转

《Python结合FreeSpire.PDFforPython实现PDF页面旋转》在日常办公或文档处理中,我们经常会遇到PDF页面方向错误的问题,本文将分享如何用Python结合FreeSpir... 目录基础实现:单页PDF精准旋转完整代码代码解析进阶操作:覆盖多场景旋转需求1. 旋转指定角度(90/27

使用Python实现在PDF中添加、导入、复制、移动与删除页面

《使用Python实现在PDF中添加、导入、复制、移动与删除页面》在日常办公和自动化任务中,我们经常需要对PDF文件进行页面级的编辑,使用Python,你可以轻松实现这些操作,而无需依赖AdobeAc... 目录1. 向 PDF 添加空白页2. 从另一个 PDF 导入页面3. 删除 PDF 中的页面4. 在

通过React实现页面的无限滚动效果

《通过React实现页面的无限滚动效果》今天我们来聊聊无限滚动这个现代Web开发中不可或缺的技术,无论你是刷微博、逛知乎还是看脚本,无限滚动都已经渗透到我们日常的浏览体验中,那么,如何优雅地实现它呢?... 目录1. 早期的解决方案2. 交叉观察者:IntersectionObserver2.1 Inter

C#自动化实现检测并删除PDF文件中的空白页面

《C#自动化实现检测并删除PDF文件中的空白页面》PDF文档在日常工作和生活中扮演着重要的角色,本文将深入探讨如何使用C#编程语言,结合强大的PDF处理库,自动化地检测并删除PDF文件中的空白页面,感... 目录理解PDF空白页的定义与挑战引入Spire.PDF for .NET库核心实现:检测并删除空白页

把Python列表中的元素移动到开头的三种方法

《把Python列表中的元素移动到开头的三种方法》在Python编程中,我们经常需要对列表(list)进行操作,有时,我们希望将列表中的某个元素移动到最前面,使其成为第一项,本文给大家介绍了把Pyth... 目录一、查找删除插入法1. 找到元素的索引2. 移除元素3. 插入到列表开头二、使用列表切片(Lis

一文详解如何使用Java获取PDF页面信息

《一文详解如何使用Java获取PDF页面信息》了解PDF页面属性是我们在处理文档、内容提取、打印设置或页面重组等任务时不可或缺的一环,下面我们就来看看如何使用Java语言获取这些信息吧... 目录引言一、安装和引入PDF处理库引入依赖二、获取 PDF 页数三、获取页面尺寸(宽高)四、获取页面旋转角度五、判断

HTML5实现的移动端购物车自动结算功能示例代码

《HTML5实现的移动端购物车自动结算功能示例代码》本文介绍HTML5实现移动端购物车自动结算,通过WebStorage、事件监听、DOM操作等技术,确保实时更新与数据同步,优化性能及无障碍性,提升用... 目录1. 移动端购物车自动结算概述2. 数据存储与状态保存机制2.1 浏览器端的数据存储方式2.1.

Kotlin Compose Button 实现长按监听并实现动画效果(完整代码)

《KotlinComposeButton实现长按监听并实现动画效果(完整代码)》想要实现长按按钮开始录音,松开发送的功能,因此为了实现这些功能就需要自己写一个Button来解决问题,下面小编给大... 目录Button 实现原理1. Surface 的作用(关键)2. InteractionSource3.