How to attach a scroll bar to a canvas in android ?
Posted
by panzerschreck
on Stack Overflow
See other posts from Stack Overflow
or by panzerschreck
Published on 2010-04-18T06:06:22Z
Indexed on
2010/04/18
6:13 UTC
Read the original article
Hit count: 986
android
|android-widget
Hello,
I am drawing up a grid on a canvas as below, I have not been able to get the scroll bar to appear, I looked around for examples, but none of them give details on drawing scroll bars for custom views.
Your help is much appreciated.
public class GridActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// i tried to do as in the documentation nothing seems to happen
LinearLayout lLayout = new LinearLayout(this);
lLayout.addView(new CustomDrawableView(this), new ViewGroup.LayoutParams(800,600));
FrameLayout fLayout = new FrameLayout(this);
fLayout.addView(lLayout, new ViewGroup.LayoutParams(800,600));
setContentView(fLayout);
}
private class GridView extends ScrollView
{
private ShapeDrawable[] mDrawable;
public GridView (Context context) {
// some initialization
}
protected void onDraw(Canvas canvas) {
for each i
mDrawable[i].draw(canvas)
}
}
}
© Stack Overflow or respective owner