引导页面的移动箭头效果 guide arrow animation
来源:互联网 发布:如何求最大公约数 算法 编辑:程序博客网 时间:2024/05/01 09:12
要实现类似效果
由于动画是非平滑的,所以不能用平移的方式来实现,这里就定时去更新在父布局的位置来是实现
先看布局代码
<RelativeLayout android: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"> <RelativeLayout android:id="@+id/guide_arrow" android:layout_width="wrap_content" android:layout_alignParentRight="true" android:layout_height="20dip" > <ImageView android:id="@+id/guide_arrow_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:src="@drawable/guide_arrow" /> <ImageView android: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" /> <ImageView android: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> <TextView android: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,这样应该就可以了,大家有更好的,欢迎交流
0 0
- 引导页面的移动箭头效果 guide arrow animation
- 如何做一个简单的Guide(引导)页面
- Raphael绘制箭头arrow
- MFC中实现的画箭头算法 (Arrow in MFC)
- js实现页面上的图片跟着鼠标箭头移动
- JS移动的箭头
- Arrow Functions—箭头函数
- 用CSS实现箭头arrow
- ES6:箭头函数 Arrow Functions
- js箭头函数 => arrow
- ios 实现引导页面效果
- ios 实现引导页面效果
- 【cocos2d-x】无限重复动作-新手引导箭头上下移动
- 按钮的animation移动
- Android - ScrollView添加提示Arrow(箭头)
- 【ES6】之 Arrow Function箭头函数
- ES6箭头函数(arrow function)
- ES6箭头函数(Arrow Functions)
- hdu4911 Inversion 2014 Multi-University Training Contest 5
- 杭电2037今年暑假不AC
- 再说下自己做过的一些系统,呵呵
- 推荐系统综述——只谈感受不谈理论
- hdu 4915 Parenthese sequence
- 引导页面的移动箭头效果 guide arrow animation
- 高质量C/C++编程指南 阅读笔记(四)类的构造函数、析构函数与赋值函数
- linux命令后台运行
- 错误-Sql Server 备份数据库时提示“无法打开备份设备”
- yuv420sp-rgb24
- 数据库编程总结
- 用eclipse运行和部署myeclipse项目
- hdu1880 hash算法学习
- 2014多校联合五(HDU 4911 HDU 4915 HDU 4920)