在我们自己new的mBitmap中也绘制了一份图片,因为我不希望每次都是调用super.dispatchDraw,所以只要isReady=true,我们就可以去调用绘制mBitmap而避免调用super.dispatchDraw()。
绘制完成图片,就是绘制黑色的遮盖和阴影了~~,就是两个Rect的绘制。
完成这些以后,我们可以简单的坐下测试,使用我们的布局。
2、测试
布局文件:
<com.zhy.view.FoldLayout xmlns:android="http://www.easck.com/apk/res/android"
xmlns:tools="http://www.easck.com/tools"
android:id="@+id/id_fold_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/xueshan" />
</com.zhy.view.FoldLayout>
Activity
package com.zhy.sample.folderlayout;
import com.zhy.view.FoldLayout;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
public class FoldLayoutActivity extends Activity
{
private FoldLayout mFoldLayout;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fold);
mFoldLayout = (FoldLayout) findViewById(R.id.id_fold_layout);
/*mFoldLayout.post(new Runnable()
{
@SuppressLint("NewApi")
@Override
public void run()
{
ObjectAnimator.ofFloat(mFoldLayout, "factor", 1, 0, 1)
.setDuration(5000).start();
}
});*/
}
}
现在的效果是,我们把mFactor改为0.6f:










