| 方法 | 意义 |
|---|---|
| startFlipping | 开始浏览 |
| stopFlipping | 停止浏览 |
| setFlipInterval | 设置View之间切换的时间间隔 |
| getAccessibilityClassName | 获取类名称 |
| isFlipping | 判断是否正在浏览 |
| setAutoStart | 设置是否自动开始浏览 |
| isAutoStart | 判断是否为自动开始浏览 |
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="1000"
android:fromXScale="0.2"
android:fromYScale="0.2"
android:toYScale="1"
android:toXScale="1"
android:pivotX="50%"
android:pivotY="50%"
>
</scale>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:toYScale="0.2"
android:toXScale="0.2"
android:pivotX="50%"
android:pivotY="50%">
</scale>
</set>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="jzfp.gs.com.animationdemo.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"></android.support.v7.widget.Toolbar>
<!--渐入动画 和 渐出动画定义-->
<ViewFlipper
android:id="@+id/vf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inAnimation="@anim/scalein"
android:outAnimation="@anim/scaleout">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/one" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/two" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/three" />
</ViewFlipper>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
private ViewFlipper viewFlipper = null;
float PosX = 0, CurrentX = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.left);
setSupportActionBar(toolbar);//设置ActionBar
viewFlipper = (ViewFlipper) findViewById(R.id.vf);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
PosX = event.getX();
break;
case MotionEvent.ACTION_MOVE:
CurrentX = event.getX();
break;
case MotionEvent.ACTION_UP:
if (CurrentX - PosX > 25.0) {//向右滑动切换到上一页
viewFlipper.showPrevious();
} else if (CurrentX - PosX < -25.0) {//向左滑动,切换到下一页
viewFlipper.showNext();
}
}
return true;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有