Android 实现iphone主屏幕文件夹展开合并效果(OpenFolder)
[java]
public class OpenFolder {
public static String TAG = "OpenFolder";
/**
* folder animaltion execution time
*/
private static int ANIMALTION_TIME = 300;
private Context mContext;
private WindowManager mWindowManager;
private int mWindowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
private OpenFolderContainer container;
private View mBackgroundView;
private View mFolderView;
private ImageView mTopView;
private ImageView mBottomView;
private int mUp_down;
private int[] mAnchorLocation = new int[2];
private int mSrceenwidth;
private int mSrceenheigh;
private int mFolderheigh;
private int offsety;
private int offsetyLast;
private boolean mIsOpened = false;
/**
* Listener that is called when this OpenFolder window is closed.
*/
public inte易做图ce OnFolderClosedListener {
/**
* Called when this OpenFolder window is closed.
*/
public void onClosed();
}
private OnFolderClosedListener mOnFolderClosedListener;
/**
* the folder open Animation Listener
*/
private Animation.AnimationListener mOpenAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mIsOpened = true;
}
};
/**
* the folder colse Animation Listener
*/
private Animation.AnimationListener mClosedAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mWindowManager.removeView(container);
// 清空画图缓存区,否则获取的还是原来的图像
mBackgroundView.setDrawingCacheEnabled(false);
mIsOpened = false;
if (mOnFolderClosedListener != null) {
mOnFolderClosedListener.onClosed();
}
}
};
private static OpenFolder openFolder;
/**
* @param context
* @return
*/
public static OpenFolder getInstance(Context context) {
if (openFolder == null) {
openFolder = new OpenFolder(context);
}
return openFolder;
}
private OpenFolder(Context context) {
mContext = context;
mWindowManager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
container = new OpenFolderContainer(mContext);
}
/**
*
* @param anchor
* folder展开参照容器
* @param backgroundView
* 当前用于显示folder的页面
* @param folderView
* folder页面
* @param folderH
* folder页面高度,dip
* @param up_down
* 0 为向上展开,否则向下展开
*/
public void openFolderView(View anchor, View backgroundView,
View folderView, int folderH, int up_down) {
mUp_down = up_down;
container.removeAllViews();
mBackgroundView = backgroundView;
mFolderheigh = dip2px(mContext, folderH);
mFolderView = folderView;
 
补充:移动开发 , Android ,