propertyanim悬浮球
来源:互联网 发布:浪登西装 怎么样 知乎 编辑:程序博客网 时间:2024/04/28 17:54
效果 : 点击图片 四周跳出四张图片 如同手机上的悬浮球xml文件:<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#555555" tools:context="com.audrey.propertyanim.Main2Activity"> <ImageView android:id="@+id/iv_top" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/top" /> <ImageView android:id="@+id/iv_right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/right" /> <ImageView android:id="@+id/iv_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/bottom" /> <ImageView android:id="@+id/iv_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/left" /> <ImageView android:id="@+id/iv_circle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/circle" /></RelativeLayout>Activity代码public class Main2Activity extends AppCompatActivity implements View.OnClickListener { private ImageView mIvTop; private ImageView mIvRight; private ImageView mIvBottom; private ImageView mIvLeft; private ImageView mIvCircle; private boolean flag;//false表示未显示,true表示已经显示了 private TextView skip; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); mIvTop = (ImageView) findViewById(R.id.iv_top); mIvRight = (ImageView) findViewById(R.id.iv_right); mIvBottom = (ImageView) findViewById(R.id.iv_bottom); mIvLeft = (ImageView) findViewById(R.id.iv_left); mIvCircle = (ImageView) findViewById(R.id.iv_circle); mIvCircle.setOnClickListener(this); skip = (TextView) findViewById(R.id.skip_tv); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_circle: if (!flag) { //点击把所有图标都展示出来 show(); } else { //点击把所有图标都收起来 dismiss(); } flag = !flag; break; } } private void show() { ObjectAnimator tranLeft = ObjectAnimator.ofFloat(mIvLeft, "TranslationX", 0f, -150f); ObjectAnimator tranRight = ObjectAnimator.ofFloat(mIvRight, "TranslationX", 0f, 150f); ObjectAnimator tranTop = ObjectAnimator.ofFloat(mIvTop, "TranslationY", 0f, -150f); ObjectAnimator tranBottom = ObjectAnimator.ofFloat(mIvBottom, "TranslationY", 0f, 150f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(tranBottom, tranLeft, tranRight, tranTop); animatorSet.setDuration(1000); animatorSet.start(); } private void dismiss() { ObjectAnimator tranLeft = ObjectAnimator.ofFloat(mIvLeft, "TranslationX", -100f, 0f); ObjectAnimator tranRight = ObjectAnimator.ofFloat(mIvRight, "TranslationX", 100f, 0f); ObjectAnimator tranTop = ObjectAnimator.ofFloat(mIvTop, "TranslationY", -100f, 0f); ObjectAnimator tranBottom = ObjectAnimator.ofFloat(mIvBottom, "TranslationY", 100f, 0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(tranBottom, tranLeft, tranRight, tranTop); animatorSet.setDuration(2000); animatorSet.start(); }}
阅读全文
0 0
- propertyanim悬浮球
- 悬浮球 / 悬浮按钮 / 辅助按钮
- floatball悬浮球总结
- 悬浮球动画
- 【android】悬浮球
- 网页悬浮球模拟
- 悬浮
- 轻松自制flyme悬浮球
- 仿iphone快速导航悬浮球
- Qt实现桌面悬浮球/不规则窗体
- 突破MIUI8权限显示悬浮球
- 利用ViewDragHelper打造悬浮球效果
- 悬浮球?只要这个就够了
- 【特效库】自实现悬浮球效果
- 不用获取权限的悬浮球
- Android TV 悬浮球模拟物理按键
- android 自定义类似91游,360应用内悬浮球(不使用系统悬浮框)
- Android 仿360悬浮球与加速球
- 网络封装
- 剑指offer 48 求1+2+3+...+n
- Android API阅读记录03
- this(转)
- Android Shape图形
- propertyanim悬浮球
- 动态创建二维数组
- Island of Survival LightOJ
- 初学者java:求两个整数的最大公约数和最小公倍数
- 类的创建与声明
- android 购物车
- Linux(CentOS6.5)下静默安装Weblogic12c(待完成)
- java基础--------基本类型转换为字符串的互相转化
- WebSocket刨根问底(转)