在安卓的CoverFlow画廊不良形象重叠 [英] Android Gallery bad image overlapping in CoverFlow
问题描述
我从这里摆弄的CoverFlow 一>,以配合我的preferences,不能修复一个问题。下面是截图:
从中心图像右边的图片是重叠在糟糕的方式。这是我的code:
保护布尔getChildStaticTransformation(查看孩子,变换T){
最终诠释childCenter = getCenterOfView(子);
INT rotationAngle = 0;
t.clear();
t.setTransformationType(Transformation.TYPE_MATRIX);
如果(childCenter == mCoveflowCenter){
transformImageBitmap((ImageView的)孩子,T,0);
} 其他 {
rotationAngle = Math.abs(mCoveflowCenter - childCenter);
transformImageBitmap((ImageView的)孩子,T,rotationAngle);
}
返回true;
}
/ **
*这是布局过程调用时该视图的大小发生了变化。如果
*你刚才添加到视图层次,你所谓的老
* 0值。
*
* @参数W该视图当前宽度。
*参数•当前这种观点的高度。
* @参数oldw这种观点的旧宽度。
* @参数oldh这种观点的旧高度。
* /
保护无效onSizeChanged(INT W,INT小时,INT oldw,诠释oldh){
mCoveflowCenter = getCenterOfCoverflow();
super.onSizeChanged(W,H,oldw,oldh);
}
/ **
*通过通过角度变换的图像位图
*
*参数的ImageView ImageView的,我们要旋转其位图的ImageView
* @参数万吨改造
*参数rotationAngle角度通过它旋转的位图
* /
私人无效transformImageBitmap(ImageView的孩子,变换T,诠释rotationAngle){
mCamera.save();
最终矩阵imageMatrix = t.getMatrix();
。最终诠释imageHeight = child.getLayoutParams()高度;
。最终诠释ImageWidth等= child.getLayoutParams()宽度;
mCamera.translate(0.0,0.0,100.0f);
浮zoomAmount = 0;
// skalowanie ZApomocą翻译聂转角?
zoomAmount = Math.abs((浮动)(rotationAngle));
Log.v(放大,Float.toString(zoomAmount));
mCamera.translate(0.0,0.0,zoomAmount - 300.0f);
mCamera.getMatrix(imageMatrix);
。imageMatrix preTranslate( - (ImageWidth等/ 2), - (imageHeight / 2));
imageMatrix.postTranslate((ImageWidth等/ 2),(imageHeight / 2));
mCamera.restore();
}
它translatimg相机的每一个画面,让小图片更加为屏幕(在logcat中值是完美的)。这是什么意思?我一定要画小图片,再大,等等?如果是这样,我怎么能做到这一点?
mCamera.translate(xTranslate,0.0,translateDepth);
在的CoverFlow
类使用上述功能,增加深度(更多积极=更小)或翻译 X
方向。你也可以使用一些缩放。使用 centerOffset
价值。服务宗旨。
I'm tinkering with CoverFlow from here to match my preferences and can't fix one problem. Here's the screenshot:
Pictures on the right from center image are overlapping in bad way. Here's my code:
protected boolean getChildStaticTransformation(View child, Transformation t) {
final int childCenter = getCenterOfView(child);
int rotationAngle = 0;
t.clear();
t.setTransformationType(Transformation.TYPE_MATRIX);
if (childCenter == mCoveflowCenter) {
transformImageBitmap((ImageView) child, t, 0);
} else {
rotationAngle = Math.abs(mCoveflowCenter - childCenter);
transformImageBitmap((ImageView) child, t, rotationAngle);
}
return true;
}
/**
* This is called during layout when the size of this view has changed. If
* you were just added to the view hierarchy, you're called with the old
* values of 0.
*
* @param w Current width of this view.
* @param h Current height of this view.
* @param oldw Old width of this view.
* @param oldh Old height of this view.
*/
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mCoveflowCenter = getCenterOfCoverflow();
super.onSizeChanged(w, h, oldw, oldh);
}
/**
* Transform the Image Bitmap by the Angle passed
*
* @param imageView ImageView the ImageView whose bitmap we want to rotate
* @param t transformation
* @param rotationAngle the Angle by which to rotate the Bitmap
*/
private void transformImageBitmap(ImageView child, Transformation t, int rotationAngle) {
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
mCamera.translate(0.0f, 0.0f, 100.0f);
float zoomAmount = 0;
//skalowanie za pomocą translate nie rotational angle?
zoomAmount = Math.abs((float) (rotationAngle));
Log.v("zoom", Float.toString(zoomAmount));
mCamera.translate(0.0f, 0.0f, zoomAmount - 300.0f);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth/2), -(imageHeight/2));
imageMatrix.postTranslate((imageWidth/2), (imageHeight/2));
mCamera.restore();
}
It's translatimg the camera for each picture, so smaller pictures are more into screen (in logcat values are perfect). What does it mean? Do I have to draw the smaller pics first, then larger, etc.? If so, how I can do that?
mCamera.translate(xTranslate, 0.0f, translateDepth);
In the Coverflow
class use the above function to increase the depth (More positive = More smaller) or translate in X
direction. Also you can use some scaling. Use the centerOffset
value as well. Serves the purpose.
这篇关于在安卓的CoverFlow画廊不良形象重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!