1
對不起,我的英語不好,但我需要你的幫助男士。我創建了一個自定義視圖 package com.gwprogram;如何在Android中滾動自定義視圖
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.ShapeDrawable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;
public class DrawCanvasView extends View{
Section[] sections;
String authorName;
String title;
String copyright;
public DrawCanvasView(Context context) {
super(context);
setFocusable(true);
}
public void setAttributes(Section[] sections, String authorName,
String title, String copyright) {
this.sections=sections;
this.authorName=authorName;
this.title=title;
this.copyright=copyright;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
//Some code for draw sections and other attributes
}
}
在活動我創造了這個代碼:
package com.gwprogram;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.Toast;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DrawCanvasView canvView=new DrawCanvasView(this);
canvView.setBackgroundColor(Color.WHITE);
setContentView(canvView);
NoteSheet sheet=new NoteSheet(canvView);
sheet.draw();
}
}
但圖像是非常大的,我需要在滾動視圖我DrawCanvasView。幫助我,我不知道如何在我的情況下創建滾動視圖。謝謝。