利用属性动画实现优酷菜单,供大家参考,具体内容如下

布局文件

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

android:layout_width="280dip"

android:layout_height="140dip"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

android:id="@+id/level3"

android:background="@drawable/level3" >

android:id="@+id/c1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_marginBottom="6dip"

android:layout_marginLeft="12dip"

android:background="@drawable/channel1" />

android:id="@+id/c2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@id/c1"

android:layout_marginBottom="12dip"

android:layout_marginLeft="28dip"

android:background="@drawable/channel2" />

android:id="@+id/c3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@id/c2"

android:layout_marginBottom="6dip"

android:layout_marginLeft="8dip"

android:layout_toRightOf="@id/c2"

android:background="@drawable/channel3" />

android:id="@+id/c4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_margin="6dip"

android:background="@drawable/channel4" />

android:id="@+id/c5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/c6"

android:layout_marginBottom="6dip"

android:layout_marginRight="8dip"

android:layout_toLeftOf="@+id/c6"

android:background="@drawable/channel5" />

android:id="@+id/c6"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/c7"

android:layout_marginBottom="12dip"

android:layout_marginRight="28dip"

android:layout_alignParentRight="true"

android:background="@drawable/channel6" />

android:id="@+id/c7"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_marginBottom="6dip"

android:layout_marginRight="12dip"

android:layout_alignParentRight="true"

android:background="@drawable/channel7" />

android:layout_width="180dip"

android:layout_height="90dip"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

android:id="@+id/level2"

android:background="@drawable/level2" >

android:id="@+id/search"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_margin="10dip"

android:background="@drawable/icon_search" />

android:id="@+id/menu"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_margin="6dip"

android:background="@drawable/icon_menu" />

android:id="@+id/myyouku"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:layout_margin="10dip"

android:background="@drawable/icon_myyouku" />

android:layout_width="100dip"

android:layout_height="50dip"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

android:background="@drawable/level1" >

android:id="@+id/home"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:background="@drawable/icon_home" />

核心代码

package com.example.uumusic.menu;

import android.content.Context;

import android.view.View;

import android.widget.ImageButton;

import android.widget.RelativeLayout;

import android.widget.Toast;

import com.example.uumusic.R;

import com.example.uumusic.fragment.base.BasePager;

import com.example.uumusic.utils.Tools;

import butterknife.ButterKnife;

import butterknife.InjectView;

/**

* Created by Administrator on 2017.06.07.0007.

*/

public class YoukuMenu extends BasePager {

@InjectView(R.id.c1)

ImageButton c1;

@InjectView(R.id.c2)

ImageButton c2;

@InjectView(R.id.c3)

ImageButton c3;

@InjectView(R.id.c4)

ImageButton c4;

@InjectView(R.id.c5)

ImageButton c5;

@InjectView(R.id.c6)

ImageButton c6;

@InjectView(R.id.c7)

ImageButton c7;

@InjectView(R.id.level3)

RelativeLayout level3;

@InjectView(R.id.search)

ImageButton search;

@InjectView(R.id.menu)

ImageButton menu;

@InjectView(R.id.myyouku)

ImageButton myyouku;

@InjectView(R.id.level2)

RelativeLayout level2;

@InjectView(R.id.home)

ImageButton home;

private boolean isLeve12 = true;

private boolean isLeve13 = true;

public YoukuMenu(Context context) {

super(context);

}

@Override

public View initView() {

View view = View.inflate(mContext, R.layout.fragment_youku, null);

ButterKnife.inject(this,view);

return view;

}

@Override

public void initData() {

//为按钮设置点击事件

home.setOnClickListener(new MyOnClickLisetner());

menu.setOnClickListener(new MyOnClickLisetner());

}

class MyOnClickLisetner implements View.OnClickListener{

@Override

public void onClick(View v) {

switch (v.getId()){

case R.id.home:

//当点击home按钮时,开始进行动画的效果

if (isLeve12){

isLeve12 = false;

Tools.hide(level2);

if (isLeve13){

isLeve13 = false;

Tools.hide(level3,200);

}

}else {

isLeve12 = true;

Tools.show(level2);

}

break;

case R.id.menu:

if (isLeve13){

isLeve13 = false;

Tools.hide(level3);

}else {

isLeve13 = true;

Tools.show(level3);

}

break;

}

}

}

}

动画工具类

package com.example.uumusic.utils;

import android.animation.ObjectAnimator;

import android.content.Context;

import android.view.View;

import android.view.ViewGroup;

import android.view.animation.RotateAnimation;

import android.widget.RelativeLayout;

/**

* Created by Administrator on 2017.06.07.0007.

*/

public class Tools {

//隐藏布局

public static void hide(ViewGroup view) {

hide(view, 0);

}

//显示布局

public static void show(ViewGroup view) {

//使用属性动画实现菜单的旋转

ObjectAnimator animator = ObjectAnimator.ofFloat(view,"rotation",180,360);

//设置动画时长

animator.setDuration(300);

animator.start();

view.setPivotX(view.getWidth()/2);

view.setPivotY(view.getHeight());

}

//延迟隐藏

public static void hide(ViewGroup view, int i) {

ObjectAnimator animator = ObjectAnimator.ofFloat(view,"rotation",0,180);

//设置动画时长

animator.setDuration(300);

//设置延迟

animator.setStartDelay(i);

animator.start();

view.setPivotX(view.getWidth()/2);

view.setPivotY(view.getHeight());

}

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持找一找教程网。

android的优酷菜单,Android利用属性动画实现优酷菜单相关推荐

  1. Android 利用属性动画实现PopupWindow背景逐渐变暗

    今天,简单讲讲android如何使用属性动画实现PopupWindow弹出后背景逐渐变暗. 昨天,记得自己讲了如何使用线程使PopupWindow弹出后背景逐渐变暗,那个其实很简单,其实还有一种代码也 ...

  2. android 一分钟倒计时动画,Android利用属性动画自定义倒计时控件

    本文介绍一下利用属性动画(未使用Timer,通过动画执行次数控制倒计时)自定义一个圆形倒计时控件,比较简陋,仅做示例使用,如有需要,您可自行修改以满足您的需求.控件中所使用的素材及配色均是笔者随意选择 ...

  3. 超酷的计步器APP(一)——炫酷功能实现,自定义水波纹特效、自定义炫酷开始按钮、属性动画的综合体验

    超酷的计步器APP(一)--炫酷功能实现,自定义水波纹特效.自定义炫酷开始按钮.属性动画的综合体验 好久没写博客了,没给大家分享技术了,真是有些惭愧.这段时间我在找工作,今年Android的行情也不怎 ...

  4. 8款帅酷的HTML5/CSS3 3D动画、图片、菜单应用

    今天要给大家分享8款帅酷的HTML5/CSS3应用,它们中包括很酷的HTML5 3D动画应用,也包括实用的CSS3图片.菜单.进度条等插件,一起来看看吧. 1.HTML5 Canvas火焰燃烧动画 如 ...

  5. 利用属性动画轻松实现 Android TV 游标动画,你缺的是几行代码

    作者: 夏至,欢迎转载,但请保留这段申明,谢谢 http://blog.csdn.net/u011418943/article/details/76687529 在 Android Tv 或者其他需要 ...

  6. Android—逐帧、补间、属性动画

    1.Tween Animation 补间动画 这类动画比较简单,一般就是平移.缩放.旋转.透明度,或者其组合,可以用代码或者xml文件的形式,推荐使用xml文件形式,因为可以复用. 四个动画效果实现类 ...

  7. Android属性动画实现TextView类似支付宝余额数字滚动

    Demo下载链接 项目中的小需求,完成类似于支付宝余额的数字滚动效果,找了网上的一个小demo,再加上郭婶的关于属性动画的文章,整理一部分代码分享给有需要的人. 下面贴出封装的TextView代码片段 ...

  8. Android 颜色渐变 属性动画

    最近用到的一个效果,见下图文字颜色渐变 (周围的晃来晃去的框框是轨迹动画,下篇博客说) 1.原理 计算机颜色由红.绿.蓝三色混合组成(值为0-255) 红.绿.蓝之间色值,按照不同大小比例 组成不同颜 ...

  9. android 蒙层动画,Android酷炫加载进度动画

    一.概述 本自定义动画进度酷炫View,是加载进度动画的自定义View,继承于ImageView来实现,主要实现蒙层加载进度的加载进度效果. 支持水平左右加载和垂直上下加载四个方向,同时也支持自定义蒙 ...

最新文章

  1. C++_重载new,delete
  2. 行业 AI 落地新范式,华为云下午茶等你来聊知识计算
  3. WWDC2019:iPad全新发布
  4. 租车信息系统数据库设计(3)
  5. python模块学习(1)
  6. html 折叠焦点图切换,jQuery层叠式图片切换焦点图插件
  7. java系列4:数组初始化(省略格式)
  8. @sql 单元测试_SQL单元测试最佳实践
  9. OpenCV配置及开发中遇到的问题
  10. dubbo和zookeper使用_Dubbox与Zookeeper简介及入门小案例
  11. litepal更好的操作sqlite3,配置与基本操作
  12. jquery扩展 $.fn
  13. Android Intent机制与常见的用法
  14. [转载] New Concept English 1——Lesson 12 Whose is this…?This is my/your/her…
  15. 思科交换机配置命令大全
  16. win10浏览器闪退_Win10专业版下Edge浏览器闪退的多种解决技巧
  17. access中本年度的四月一日_Access数据库程序设计上机操作练习试题2.doc
  18. 构建请求header fake_useragent安装以及解决方法
  19. python登录qq邮箱爬邮件_如何使用Python登录邮箱发送邮件
  20. ssb门限_SSB调制

热门文章

  1. C8—Qt实现天气预报
  2. UE4 使用UnrealDatasmithMaxExporter插件解决3DMax导入ue4坐标问题
  3. 程序员才能看得懂的段子,内含表情包,吃饭的时候别点!
  4. 短语文:很好很强大 全民参与正在使语文变短zz
  5. 最火的计算机病毒 熊猫烧香,熊猫烧香-世界知名计算机病毒排行榜-天天排行网...
  6. 浏览器工作原理/浏览器是如何渲染页面?
  7. 钱扣了,订单却是未支付,用户炸了——聊聊如何防止支付掉单
  8. 【基于FPGA的运动目标实时跟踪检测】
  9. RTX2060和RTX2070的区别
  10. 【golang音频库】发现了一个特别棒的音频库,beep,使用docker方式驱动设备,可以使用golang进行控制音频设备,播放音乐。