android 属性动画应用,不知道这个效果好看,反正挺好玩的!
来源:互联网 发布:网络迷情演员表 编辑:程序博客网 时间:2024/05/01 13:36
前两天为了看漫画,下载了一个动漫APP,打开一看,滑动的时候竟然下面的TAB跟上面的TITEL都隐藏掉了,变成全屏了,感觉好牛逼的样子哦,当初我以为是隐藏跟现实的属性那,后来一仔细看,不是,那么只有动画来实现了,看来还得用属性动画来实现:属性动画嘛就是改变了对象的属性了。不知道这个效果好不好,应该适合一些全屏阅读类的app.
先看看它的效果:
在看看咱们的效果:
好了 ,代码很少就能实现这个效果:
package com.example.hidetitle;import android.annotation.SuppressLint;import android.app.Activity;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.view.ViewPropertyAnimator;import android.view.View.OnTouchListener;import android.widget.ArrayAdapter;import android.widget.LinearLayout;import android.widget.ListView;public class MainActivity extends Activity {private boolean ismove = true;private ViewPropertyAnimator animatebottom,animatetop;@SuppressLint("NewApi")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ListView mListView = (ListView) findViewById(R.id.my_listview);LinearLayout tabbottom = (LinearLayout) findViewById(R.id.tabbottom);LinearLayout tabtop = (LinearLayout) findViewById(R.id.tabtop);animatebottom = tabbottom.animate();animatetop = tabtop.animate();ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1);for (int i = 0; i < 100; i++) {adapter.add(i + "");}mListView.setAdapter(adapter);mListView.setOnTouchListener(new OnTouchListener() {private float y;private boolean down = true;private float lasty;@Overridepublic boolean onTouch(View v, MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_DOWN:y = event.getY();if (down) {lasty = y;}down = false;break;case MotionEvent.ACTION_MOVE:break;case MotionEvent.ACTION_UP:down = true;if (lasty - event.getY() < -5) {onScrollReset();} else if (lasty - event.getY() > 5) {onScroll();}break;}return false;}});}@SuppressLint("NewApi")public void onScroll() {if (ismove) {animatebottom.setDuration(500).translationY(200);animatetop.setDuration(500).translationY(-200);ismove = false;}}@SuppressLint("NewApi")public void onScrollReset() {if (!ismove) {animatebottom.setDuration(500).translationY(0);animatetop.setDuration(500).translationY(0);ismove = true;}}}xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/my_listview" android:layout_width="match_parent" android:layout_height="match_parent" > </ListView> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/tabbottom" android:layout_width="match_parent" android:layout_height="50dip" android:layout_alignParentBottom="true" android:background="#880090D9" android:gravity="center" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="标题" android:textColor="#ffffff" android:textSize="18sp" /> </LinearLayout> <LinearLayout android:id="@+id/tabtop" android:layout_width="match_parent" android:layout_height="50dip" android:layout_alignParentTop="true" android:background="#880090D9" android:gravity="center" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="标题" android:textColor="#ffffff" android:textSize="18sp" /> </LinearLayout> </RelativeLayout></FrameLayout>
好玩!
5 0
- android 属性动画应用,不知道这个效果好看,反正挺好玩的!
- android 属性动画应用,不知道这个效果好看,反正挺好玩的!
- 好看的android动画效果
- Android 好看的loading动画效果
- 不知道这里做数据化营销的多不多,反正我是做这个行业的
- 挺好玩的uniqueID&uniqueNumber属性
- android好看的加载动画
- 你不知道的Android 5.0转场共享动画实现炫酷效果
- Android 利用属性动画结合贝塞尔曲线方程编写好看的动画.
- 挺好玩的
- 九九乘法表挺好玩的
- 有两张图片挺好看的,不知道是什么意思。
- 挺好玩的C语句
- 挺好玩的C语句
- 打人游戏,挺好玩的
- Android属性动画弹出效果
- 你知道什么是数据结构吗?反正我不知道。
- 小游戏(名字不知道叫什么好,反正是好像打靶的那种游戏)
- Linux系列之网卡自启动
- 导航窗口模块(NativeWidget)
- MfgTool (i.MX53)使用
- 我的学习之旅 keybaord.h和keyboard.c
- opencv中setMousecallback的用法
- android 属性动画应用,不知道这个效果好看,反正挺好玩的!
- 欢迎使用CSDN-markdown编辑器
- select查询 like模糊查询 as别名定义 逻辑运算符
- wireshark使用总结
- mysql 批量插入受参数配置限制的解决 max_allowed_packet
- How to crawl a quarter billion webpages in 40 hours
- 完美解决 Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml
- 将bash切换到zsh
- 架构模式学习-Layers模式