可能是我继承的类有问题吧...不过重新做了一个继承View的,而且对整个画布进行旋转,效果是图片旋转了,但局限于canvas上View限定的区域,图片不能完全显示,而且还要重写其监听事件。
  这是代码:旋转整个canvas 
public RotateView(Context context, AttributeSet attrs) {
         super(context, attrs);
// TODO Auto-generated constructor stub
       mBackGroudDrawableId=attrs.getAttributeResourceValue(namespace, "background",R.drawable.qq);
      mBackGroudDrawable = context.getResources().getDrawable(mBackGroudDrawableId);
       mRotateDegrees=attrs.getAttributeFloatValue(namespace, "rotateDegrees",0.0f);
}
@Override
           protected void onDraw(Canvas canvas) {
                         super.onDraw(canvas);
                                     if (mRotateDegrees==90.0f) {
                                           canvas.rotate(mRotateDegrees, 0, 0);
                                           canvas.translate(0, -mBackGroundHeight);
                                          }else{
                                           canvas.rotate(mRotateDegrees, mBackGroundWidth/2, mBackGroundHeight/2);
}
                                             mBackGroudDrawable.setBounds(0, 0, mBackGroundWidth, mBackGroundHeight);
                                             mBackGroudDrawable.draw(canvas);
}
@Override
                                    protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
                                                   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                                                    mBackGroundHeight=mBackGroudDrawable.getMinimumHeight();
                                                   mBackGroundWidth=mBackGroudDrawable.getMinimumWidth();

                                                     if (mRotateDegrees==90.0f) {
                                                               setMeasuredDimension(mBackGroundHeight, mBackGroundWidth);
                                                    }else{
                                                           setMeasuredDimension(mBackGroundWidth, mBackGroundHeight);
}


}

但效果是:  
  那我想知道有没有一种方法,可以使Button旋转,当我单击叠加在一起的Button中某一个Button时(触发的是该Button未被其他Button覆盖的部分),能够响应我所设定事件,并且我要在每个Button上加载我喜欢的背景图片。
  上述,也许只是其中方法的一种(对整个ImageButton旋转),还有一种就是计算每张叠加图片的位置区域,通过一个判断比较的过程来设置响应事件,这种方法比较麻烦,暂时不予考虑.
  希望各位热爱Android的童鞋,可以给我小小的建议....小弟真的不胜感激!!!!!!!

posted on 2010-10-20 10:11  sonken_SK  阅读(117)  评论(0编辑  收藏  举报