android - How can I scroll my custom view? I want to see the shapes drawn over the bounds of the screen -
i have custom view ...
package nan.salsa.goal.customview; import android.r; import android.content.context; import android.graphics.canvas; import android.graphics.drawable.shapedrawable; import android.graphics.drawable.shapes.rectshape; import android.util.attributeset; import android.util.log; import android.view.view; public class dayview extends view { private static string tag="dayview"; private shapedrawable mdrawable; public dayview(context context) { super(context); } public dayview(context context, attributeset attrs) { super(context, attrs); init(); } public dayview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); init(); } public void init() { int x = 10; int y = 10; mdrawable = new shapedrawable(new rectshape()); mdrawable.getpaint().setcolor(color.green); mdrawable.setbounds(x, y, x + (width - (x * 2)), y + (height - (y*2))); mdrawable.draw(canvas); (int = 1; < 30; i++) { boxdrawable = new shapedrawable(new rectshape()); boxdrawable.setbounds(x + x , y + (100 * i) , x + (width - ((x + x) * 2)), y + (100 * i) + 50); boxdrawable.getpaint().setcolor(color.red); boxdrawable.draw(canvas); } } @override protected void ondraw(canvas canvas) { // todo auto-generated method stub super.ondraw(canvas); setbackgroundcolor(r.color.black); mdrawable.draw(canvas); } }
with simple configuration file :
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#e06f00"> <nan.salsa.goal.customview.dayview android:id="@+id/dayview" android:layout_height="match_parent" android:layout_width="fill_parent" /> </linearlayout>
in view want scroll see shapes drawn on bounds of screen ..
how can it?
regards, antonio musella
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#e06f00"> <scrollview android:layout_width="fill_parent" android:layout_height="fill_parent"> <nan.salsa.goal.customview.dayview android:id="@+id/dayview" android:layout_height="match_parent" android:layout_width="fill_parent" /> </scrollview> </linearlayout>
Comments
Post a Comment