Hi All, I am trying to create an application with UI totally in Java.
I have a view whose's onDraw function displays a large volume of text. To add scrolling ability , i have created a new ScrollView and added the previous view as a child. The contents are being displayed on the screen , but the scrolling functionality is not working. Could anyone please guide me so as to how can i enable vertical n horizontal scrolling of the text. Here is the code snippet :- import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.os.Bundle; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.ScrollView; public class TempScrollView extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ParentView parentView = new ParentView(this); setContentView(parentView); } private class ChildView extends View{ public ChildView(Context c) { super(c); this.setLayoutParams(new LayoutParams (LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); } public void onDraw(Canvas c){ Paint p = new Paint(); p.setColor(Color.BLUE); for(int i=0;i<200;i++){ c.drawText("This is a string",(float)0.0,(float)(i*10.0),p); } } } private class ParentView extends ScrollView{ public ParentView(Context c) { super(c); childView = new ChildView(c); this.setLayoutParams(new LayoutParams (LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); this.addView(childView); this.setFocusable(true); this.setFocusableInTouchMode(true); } public void onDraw(Canvas c) { childView.onDraw(c); } private ChildView childView; } } Any help would be greatly appreciated... Thanks And Regards
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en