How to make programmatically added annotation sub-view scrollable over keyboard

295 views Asked by At

I want to use annotation on my PDF view.

For loading PDF, I have used AndroidPdfViewer library

Now I have added view programmatically over it.

ScrollView - If I use scrollview which is having edit text, as soon as my keyboard opens, my custom added scrollview resizes to the available screen area. Now my PDF view and custom view are not sync and i tried giving custom offset any many other provided solution, but not working in my case. So How can I make both in sync or in other words make both view scroll to same y position.

I am setting android:windowSoftInputMode="adjustResize" in manifest.

activity_main.xml file.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.github.barteksc.pdfviewer.PDFView>

</RelativeLayout>

Programmatically added layout is,

     ScrollView scrollView = new ScrollView(this);
            scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100000));
            scrollView.setBackgroundColor(ContextCompat.getColor(this, R.color.bg2));

  EditText et = new EditText(this);
                et.setPadding(10, 10, 0, 0);
                et.setTextSize(8);
                et.setGravity(Gravity.TOP);
                et.setBackground(getResources().getDrawable(R.drawable.edittext_border));

scrollview.addView(et);

pdfView.addView(scrollview); // pdfView = findViewById(R.id.pdfView);

So how to make pro-grammatically added annotation sub-view scroll-able over keyboard or make pdf and annotation view scroll in sync while keyboard is open.

0

There are 0 answers