Tried to build and add a customview on a ScrollView. But it wont Scroll.
While overriding onMeasure - it's not recognized.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
</ScrollView>
//tried above making as child.
Code:
ScrollView scrollView = findViewById(R.id.scrollView);
//LinearLayout linearLayout = findViewById(R.id.line);
myView gw = new myView(this,bitmap);
// ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(480,800);
scrollView.addView(gw);
scrollView.setFillViewport(true);
myView Class draws bitmap using this code:
public class myView extends SurfaceView implements View.OnTouchListener {
private Bitmap bitmap;
private SurfaceHolder holder;
public myView(Context context, Bitmap bitmap) {
super(context);
holder = getHolder();
this.bitmap = bitmap;
}
.....
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
canvas.drawBitmap(bitmap, 10, 20, null);
canvas.drawPath(path, paint);
canvas.drawText("Second floor", x, y + 600, paint1);
Log.d("test", "drawing....");
}
View draws but wont scroll. How to make it scroll?