是否设置可点击或可选中呢? setClickable setSelectable
解决方案 »
- android如何获取实时天气或者如何根据城市名获得对应的编号
- 无法开始service 求助啊,代码全部附上
- RedioGroup动态添加RedioButton问题,急~~
- 泪奔求解
- BroadcastReceiver和intent 寻找问题
- Android 2.0 游戏开发实战宝典-源代码-1-12章
- findviewbyid参数一定要int 没办法就把存了id的数组强行转换成了int 还是不能运行 怎么破?
- android 里的后台服务中想显示对话框,怎么实现?
- 各位朋友,我想用手机点灯一个LED灯,要怎么操作。大神给点思路。
- 使用android.widget.seekbar,但是onProgressChanged没触发
- 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子项左边对齐,但是单击区域却不对称了,搞成右边对齐了。怎么办呢?