編輯:關於Android編程
ViewPager做導航想不想有這樣的效果:
比如說有四張圖片,下面有四個圓點,當頁面滑動的時候一個點變大一個點變小(或者是一個點變小一個點變大),等於說同時在執行兩個動畫。
<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHByZSBjbGFzcz0="brush:java;">package com.example.day_2014_10_17_viewpager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import com.nineoldandroids.view.ViewHelper;
import com.panpass.adapter.MyViewPagerAdapter;
import com.panpass.view.MyViewPager;
import com.panpass.view.MyViewPager.DiyPageScrollListener;
public class MainActivity extends Activity {
private Context mContext = this;
private MyViewPager mViewPager;
private ImageView imageView1, imageView2, imageView3, imageView4;
private ArrayList
package com.panpass.adapter;
import java.util.ArrayList;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
public class MyViewPagerAdapter extends PagerAdapter {
private ArrayList
package com.panpass.view;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
public class MyViewPager extends ViewPager {
private boolean left = false;
private boolean right = false;
private boolean isScrolling = false;
private int lastValue = -1;
private ChangeViewCallback changeViewCallback = null;
public MyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyViewPager(Context context) {
super(context);
init();
}
private DiyPageScrollListener listener1;
public interface DiyPageScrollListener{
void diyOnPageScrollListener(int position, float positionOffset,
int positionOffsetPixels,boolean left,boolean right);
}
public void setDiyOnPageScrollListener(DiyPageScrollListener listener){
this.listener1 = listener;
}
@Override
protected void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
listener1.diyOnPageScrollListener(position, positionOffset, positionOffsetPixels,left,right);
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
/**
* init method .
*/
private void init() {
// setOnPageChangeListener(listener);
}
/**
* listener ,to get move direction .
*/
public OnPageChangeListener listener = new OnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int arg0) {
if (arg0 == 1) {
isScrolling = true;
} else {
isScrolling = false;
}
if (arg0 == 2) {
if(changeViewCallback!=null){
changeViewCallback.changeView(left, right);
}
right = left = false;
}
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
if (isScrolling) {
if (lastValue > arg2) {
// 遞減,向右側滑動
right = true;
left = false;
} else if (lastValue < arg2) {
// 遞減,向右側滑動
right = false;
left = true;
} else if (lastValue == arg2) {
right = left = false;
}
}
lastValue = arg2;
}
@Override
public void onPageSelected(int arg0) {
if(changeViewCallback!=null){
changeViewCallback.getCurrentPageIndex(arg0);
}
}
};
/**
* 得到是否向右側滑動
* @return true 為右滑動
*/
public boolean getMoveRight(){
return right;
}
/**
* 得到是否向左側滑動
* @return true 為左做滑動
*/
public boolean getMoveLeft(){
return left;
}
/**
* 滑動狀態改變回調
* @author zxy
*
*/
public interface ChangeViewCallback{
public void changeView(boolean left,boolean right);
public void getCurrentPageIndex(int index);
}
public void setChangeViewCallback(ChangeViewCallback callback){
changeViewCallback = callback;
}
}
上篇文章簡單描述了有關如何實現逐幀動畫(Frame Animation),如何還未了解逐幀動畫(Frame Animation)。今天這篇文章就來描述補間動畫(Tween
----下載JDK(Java Dev Kit) 官方下載:http://www.oracle.com/technetwork/java/javase/download
截取BlueStacks安卓模擬器屏幕圖片,有時候想截圖分享一下屏幕,那麼改如何快速截取整個BlueStacks屏幕哪,怎樣把BlueStacks屏幕圖片保
簡單的日歷實現,只是顯示了每一個月,沒有顯示當天和記事這些功能主要是計算月初是周幾,月末是周幾,然後相應的顯示上一月多少天和下一月多少天。先看一下關於日期的用到的幾個工具