我正在开发一个应用程序,它可以Froyo
在JellyBean
. 我有一个扩展 PageTransformer 的类,如下所示:
import android.support.v4.view.ViewPager.PageTransformer;
import android.view.View;
public class ZoomOutPageTransformer implements PageTransformer {
private static float MIN_SCALE = 0.85f;
private static float MIN_ALPHA = 0.5f;
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
if (position < -1) {
view.setAlpha(0);
} else if (position <= 1) {
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
float vertMargin = pageHeight * (1 - scaleFactor) / 2;
float horzMargin = pageWidth * (1 - scaleFactor) / 2;
if (position < 0) {
view.setTranslationX(horzMargin - vertMargin / 2);
} else {
view.setTranslationX(-horzMargin + vertMargin / 2);
}
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
view.setAlpha(MIN_ALPHA +
(scaleFactor - MIN_SCALE) /
(1 - MIN_SCALE) * (1 - MIN_ALPHA));
} else {
view.setAlpha(0);
}
}
}
问题是,在这个类中编写的方法被添加了API level 11
,我有最小的 .sdk 版本API level 8
。以下是 API 级别 11 中添加的方法:
setAlpha()
setTranslationX()
setScaleX()
setScaleY()
有什么办法可以解决这个问题?