你可以滚动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>
答案 0 :(得分: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>
答案 1 :(得分: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);
}
MainActivity
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);
}