是否设置可点击或可选中呢? setClickable setSelectable
解决方案 »
- adb connect时出错,怎么解决?
- Android ListView点击按钮产生的问题
- 我写了一个HorizontalScrollView,是动态的添加子项,该怎么让其自动显示刚添加的子项,
- 在Launcher桌面源码中,如何获取一个应用的“包名”、“应用名称”还有“应用的图标”
- surfaceView 和 gesture 如何使用呢
- sdcard看不到任何文件目录,求大神!
- 如何解决view 宽和高的问题哦
- 动态修改非本Activity的布局的问题
- 快的打车是如何把钱直接从用户账号打到出租车司机的支付宝账号上的
- android studio cmake 编译第三方源码,提示h文件找不到
- Android 怎么访问数据库
- andriod 蓝牙mic,按键如何监听
public class CGallery extends Gallery
{
private Camera mCamera;
private int mWidth;
private int mPaddingLeft;
private boolean flag;
private static int firstChildWidth;
private static int firstChildPaddingLeft; public CGallery(Context context)
{
super(context);
mCamera = new Camera();
this.setStaticTransformationsEnabled(true);
}
public CGallery(Context context, AttributeSet attrs) {
super(context, attrs);
mCamera = new Camera();
//setAttributesValue(context, attrs);
this.setStaticTransformationsEnabled(true);
}
public CGallery(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
mCamera = new Camera();
//setAttributesValue(context, attrs);
this.setStaticTransformationsEnabled(true);
}
private void setAttributesValue(Context context, AttributeSet attrs)
{
TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[] { attr.paddingLeft });
mPaddingLeft = typedArray.getDimensionPixelSize(0, 0);
typedArray.recycle();
} protected boolean getChildStaticTransformation(View child, Transformation t)
{
t.clear();
t.setTransformationType(Transformation.TYPE_MATRIX);
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
if (flag)
{
firstChildWidth = getChildAt(0).getWidth();
firstChildPaddingLeft = getChildAt(0).getPaddingLeft();
flag = false;
}
mCamera.translate(firstChildWidth / 2 + firstChildPaddingLeft + mPaddingLeft - mWidth / 2, 0f, 0f);
mCamera.getMatrix(imageMatrix);
mCamera.restore();
return true;
}
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
if (!flag)
{
mWidth = w * 2;
getLayoutParams().width = mWidth;
flag = true;
}
super.onSizeChanged(w, h, oldw, oldh);
}
}
上面把gallery的item子项左边对齐,但是单击区域却不对称了,搞成右边对齐了。怎么办呢?