java
package com.example.ScrollView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
public class ScrollViewTest extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scrollviewtest);
ScrollView svw = (ScrollView)findViewById(R.id.scr);
// svw.setVerticalScrollBarEnabled(false);
svw.addView(new ColorView(this));
}
}
class ColorView extends View{
public ColorView(Context context){
super (context);
}
public void onDraw(Canvas canvas){
Paint Pnt = new Paint();
for(int y=0; y<1024; y+=4){
Pnt.setARGB(255, 255-y/4, 255-y, 255);
canvas.drawRect(0, y,500,y+4,Pnt);
}
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
setMeasuredDimension(500,1024);
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scr"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ScrollView>
실행하면 The application android.scrollview (process com.example.scrollvie)has stopped unexpectedly.please try again 나오는데
이유를 모르겠어요 도와주세요ㅠ.ㅠ



