0

你可以滚动由 Canvas 绘制的比屏幕大的图像吗?用scrollview可以解决吗?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

 <com.abstractargument.CustomView
            android:id="@+id/customView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />


</ScrollView>
4

2 回答 2

0
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >

 <com.abstractargument.CustomView
            android:id="@+id/customView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


</ScrollView>
于 2013-05-23T01:51:07.480 回答
0
public class CustomView extends ImageView {


    int w,h;
    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);




    }


    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        this.canvas=canvas; 



    }




    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //registriamo le dimensioni della view
        w=MeasureSpec.getSize(widthMeasureSpec);
        h=MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(w,h);
    }

}

主要活动

  public void drawC(){
            bmp = Bitmap.createBitmap(tampil.getWidth(), tampil.getHeight(), Config.ARGB_8888);
            Canvas c = new Canvas(bmp);
            tampil.draw(c);



            py+=150;
            c.drawCircle(px, py, 70, pPaint); 
            c.drawText("argomentoP", px-50, py, textPaint);


            tampil.setImageBitmap(bmp);
        }
于 2013-05-23T15:23:15.407 回答