android 携程页面,android 仿携程首页源码(自定义button)
【实例简介】
【实例截图】
【核心代码】
package com.example.xiechengdemo;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;
import android.widget.TextView;
public class HomeButtonView extends FrameLayout {
private ScaleAnimation animation_down;
private ScaleAnimation animation_up;
private boolean attri_doAnim;// 是否执行动画,在xml属性中可配置,默认为ture;
private TextView textview;
private HomeBtnOnClickListener homeBtnOnClickListener;
public interface HomeBtnOnClickListener {
void onClickDown(HomeButtonView homebtn);
void onClickUp(HomeButtonView homebtn);
}
public void setHomeBtbOnClickListener(
HomeBtnOnClickListener homeBtnOnClickListener) {
this.homeBtnOnClickListener = homeBtnOnClickListener;
}
public HomeButtonView(Context paramContext) {
this(paramContext, null);
}
public HomeButtonView(Context paramContext, AttributeSet paramAttributeSet) {
this(paramContext, paramAttributeSet, 0);
}
public HomeButtonView(Context paramContext, AttributeSet paramAttributeSet,
int paramInt) {
super(paramContext, paramAttributeSet, paramInt);
TypedArray localTypedArray = paramContext.obtainStyledAttributes(
paramAttributeSet, R.styleable.home_button);
if (localTypedArray != null) {
// 得到xml中设置的属性值
this.attri_doAnim = localTypedArray.getBoolean(
R.styleable.home_button_doAnim, true);
localTypedArray.recycle();
}
loadAnim();
}
// 设置动画
private void loadAnim() {
ScaleAnimation localScaleAnimation1 = new ScaleAnimation(1.0F, 0.95F,
1.0F, 0.95F, 1, 0.5F, 1, 0.5F);
localScaleAnimation1.setFillAfter(true);
localScaleAnimation1.setDuration(200L);
this.animation_down = localScaleAnimation1;
ScaleAnimation localScaleAnimation2 = new ScaleAnimation(0.95F, 1.0F,
0.95F, 1.0F, 1, 0.5F, 1, 0.5F);
localScaleAnimation2.setFillAfter(true);
localScaleAnimation2.setDuration(200L);
this.animation_up = localScaleAnimation2;
this.animation_up.setAnimationListener(new AnimaListen(this));
}
private void start_AnimDown() {
invalidate();
startAnimation(this.animation_down);
}
private void start_AnimUp() {
invalidate();
startAnimation(this.animation_up);
}
public boolean onTouchEvent(MotionEvent paramMotionEvent) {
switch (paramMotionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("cc", "HomeBtn==>ACTION_DOWN");
if (attri_doAnim) {
if (homeBtnOnClickListener != null) {
homeBtnOnClickListener.onClickDown(this);
}
start_AnimDown();
return true;
}
break;
case MotionEvent.ACTION_MOVE:
Log.d("cc", "HomeBtn==>ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
if (homeBtnOnClickListener != null) {
homeBtnOnClickListener.onClickUp(this);
}
Log.d("cc", "HomeBtn==>ACTION_UP");
if (attri_doAnim) {
start_AnimUp();
return true;
}
break;
default:
break;
}
return true;
}
class AnimaListen implements Animation.AnimationListener {
AnimaListen(HomeButtonView paramHomeButtonView) {
}
public void onAnimationEnd(Animation arg0) {
}
public void onAnimationRepeat(Animation paramAnimation) {
}
public void onAnimationStart(Animation paramAnimation) {
}
}
}
android 携程页面,android 仿携程首页源码(自定义button)相关推荐
- android 快传 源码_安卓APP仿茄子快传源码,Android项目源码类似茄子快传的快传项目包括服务端...
适用范围:安卓APP仿茄子快传源码,Android项目源码类似茄子快传的快传项目包括服务端 演示地址:(以截图为准) 运行环境:Android+PC+web 其他说明: 本项目是一个基于安卓的类似茄子 ...
- Android 控件GridView之仿支付宝钱包首页带有分割线的GridView九宫格的完美实现
Android控件GridView之仿支付宝钱包首页带有分割线的GridView九宫格的完美实现 关注finddreams:http://blog.csdn.net/finddreams/articl ...
- android仿iphone苹果桌面源码拖拉排
android仿iphone苹果桌面源码拖拉排序哦 仿苹果桌面 仿iphone ios桌面 launcher 本人见市场上很少仿排序拖拉这样的算法.所以改android源码.供大家学习使用哦. 这是a ...
- Android应用源码仿暴风影音安卓客户端源码
Android应用源码仿暴风影音安卓客户端源码 本项目是一个模仿暴风影音的UI项目源码,仿照的界面有菜单页,主页,分类页等,项目内的所有数据都使用的本地模拟数据,仿照度一般在大分辨设备上布局显示会有问 ...
- android版高仿淘宝客户端源码V2.3
android版高仿淘宝客户端源码V2.3,这个版本我已经更新到2.3了,源码也上传到源码天堂那里了,大家可以看一下吧,该应用实现了我们常用的购物功能了,也就是在手机上进行网购的流程的,如查看产品(浏 ...
- android 仿网易新闻客户端源码都有
原文:android 仿网易新闻客户端源码都有 android 仿网易新闻服务端源码 源代码下载地址: http://www.zuidaima.com/share/1550463560944640.h ...
- 【Android 插件化】Hook 插件化框架 ( 从源码角度分析加载资源流程 | Hook 点选择 | 资源冲突解决方案 )
Android 插件化系列文章目录 [Android 插件化]插件化简介 ( 组件化与插件化 ) [Android 插件化]插件化原理 ( JVM 内存数据 | 类加载流程 ) [Android 插件 ...
- Android Glide图片加载框架(二)源码解析之into()
文章目录 一.前言 二.源码解析 1.into(ImageView) 2.GlideContext.buildImageViewTarget() 3.RequestBuilder.into(Targe ...
- Android Glide图片加载框架(二)源码解析之with()
文章目录 一.前言 二.如何阅读源码 三.源码解析 1.with() Android Glide图片加载框架系列文章 Android Glide图片加载框架(一)基本用法 Android Glide图 ...
最新文章
- 手动建库11.2.0.4
- linux下的共享库(动态库)和静态库
- Java多线程:Semaphore
- 计算机第二阶段在线作业冯,中国石油大学(北京)《计算机应用基础》第一次在线作业 2...
- 【Android AAR】1 分钟不用改任何代码在 Eclipse 中使用 AAR
- ConcurrentHashMap的源码分析-put方法第四阶段
- Contest2162 - 2019-3-28 高一noip基础知识点 测试5 题解版
- 要不要选 qt tool_小户型儿童房要不要做高低床?优劣都告诉你,自己选
- 7-8 最长连续递增子序列 (15 分)
- UnhandledPromiseRejectionWarning报错send()的处理
- Java程序员月薪三万,需要技术达到什么水平?
- Atitit 贝叶斯算法的原理以及垃圾邮件分类的原理
- muddleftpd配置和用法
- 模式识别、机器学习与深度学习
- 电源功耗压力测试软件,整机功耗测试_机箱电源新闻-中关村在线
- 视频采集卡是什么?采集卡的妙用!
- 《我爱我的祖国》受捧 再现专线另类舌尖上中国
- ant design of vue中表格列内容过长,需要截取并且鼠标滑过悬浮显示全部内容
- 【译】设计响应式图片的3种解决方法
- 数据合并中pd.merge()和pd.concat()区别