旋转ZoomControls

时间:2011-03-24 00:24:55

标签: android view rotation

好的,我已经尝试过扩展ZoomControls类,我已经按照文档,我已经阅读了过去旋转视图的例子,但没有任何作用。这是我的班级:

package imgViewer.Viewer;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ZoomControls;

class TransformingZoomControls extends ZoomControls {

    public TransformingZoomControls(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onDraw(Canvas canvas) {
         //canvas.save();
         canvas.rotate(45,20,20);
         super.onDraw(canvas);
         //canvas.restore();
    }
}

main.xml中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:layout_gravity="center_vertical" android:orientation="vertical"> 

    <FrameLayout android:layout_width="match_parent" android:id="@+id/frameLayout1" android:layout_height="fill_parent">

        <RelativeLayout android:layout_width="wrap_content" android:id="@+id/imgAccessBtnsContainer" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom">        
            <ImageButton android:src="@drawable/icon" android:layout_width="wrap_content" android:id="@+id/btnPrevImg" android:layout_height="wrap_content" android:layout_alignParentLeft="true" />
            <ImageButton android:src="@drawable/icon" android:layout_width="wrap_content" android:id="@+id/btnNextImg" android:layout_height="wrap_content" android:layout_toRightOf="@id/btnPrevImg" />
        </RelativeLayout>   

        <RelativeLayout android:layout_width="wrap_content" android:id="@+id/rotateBtnsContainer" android:layout_height="wrap_content" android:layout_gravity="left|bottom">
            <ImageButton android:src="@drawable/icon" android:layout_width="wrap_content" android:id="@+id/btnRotateLeft" android:layout_height="wrap_content" android:layout_alignParentTop="true" />
            <ImageButton android:src="@drawable/icon" android:layout_width="wrap_content" android:id="@+id/btnRotateRight" android:layout_height="wrap_content" android:layout_below="@id/btnRotateLeft" />
        </RelativeLayout>       

        <imgViewer.Viewer.TransformingZoomControls android:id="@+id/zoomControls" android:layout_width="wrap_content" android:layout_height="wrap_content"  />  
    </FrameLayout>

    <ImageView android:id="@+id/imagePanel" android:layout_width="fill_parent" android:layout_height="fill_parent">    
    </ImageView>

</LinearLayout>

如代码块中所示,我甚至尝试不使用Save / Restore,希望实际显示出一些变化,但没有骰子。是不可能覆盖这个类??

0 个答案:

没有答案