//////////////////////////////////////////////////////////////////////////////////////
public
class
Main
extends
Activity
{
// public this_canvas this_canvas;
public
DrawView draw_view;
public
ScrollView scroll_view;
public
HorizontalScrollView h_scroll_view;
public
LinearLayout lin_layout;
public
Canvas this_canvas;
@Override
public
void
onCreate(Bundle savedInstanceState)
{
DrawView main_draw_view;
super
.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
lin_layout =
new
LinearLayout(
this
);
scroll_view =
new
ScrollView(
this
);
h_scroll_view =
new
HorizontalScrollView(
this
);
scroll_view.setLayoutParams(
new
LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
h_scroll_view.setLayoutParams(
new
LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
lin_layout.setLayoutParams(
new
LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
lin_layout.setOrientation(LinearLayout.VERTICAL);
Bitmap mBitmap = Bitmap.createBitmap(
630
,
870
, Bitmap.Config.ARGB_8888);
this_canvas =
new
Canvas(mBitmap);
main_draw_view =
new
DrawView(
this
);
main_draw_view.setLayoutParams(
new
LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
scroll_view.addView(main_draw_view);
h_scroll_view.addView(scroll_view);
setContentView(h_scroll_view);
}
//////////////////////////////////////////////////////////////////////////////////////
public
class
DrawView
extends
View
{
Context app_context;
public
DrawView(Context context)
{
super
(context);
app_context = context;
DisplayMetrics metrics =
new
DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
}
// onMeasure must be included otherwise one or both scroll views will be compressed to zero pixels
// and the scrollview will then be invisible
@Override
protected
void
onMeasure(
int
widthMeasureSpec,
int
heightMeasureSpec)
{
int
width =
2000
;
int
height =
3000
+
50
;
// Since 3000 is bottom of last Rect to be drawn added and 50 for padding.
setMeasuredDimension(width, height);
}
@Override
public
void
onDraw(Canvas canvas)
{
this_canvas = canvas;
// ToDo: Put drawing code in here
}
}
}