我想在我的 PDF 视图上使用注释。
为了加载 PDF,我使用了AndroidPdfViewer 库
现在我以编程方式添加了视图。
ScrollView - 如果我使用scrollview
的是编辑文本,只要我的键盘打开,我的自定义添加scrollview
调整到可用屏幕区域。现在我的 PDF 视图和自定义视图不同步,我尝试给自定义偏移提供任何其他提供的解决方案,但在我的情况下不起作用。那么如何使两者同步或换句话说使两个视图滚动到相同的 y 位置。
我正在设置android:windowSoftInputMode="adjustResize"
清单。
activity_main.xml 文件。
<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>
以编程方式添加的布局是,
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);
那么如何使以编程方式添加的注释子视图可在键盘上滚动或使 pdf 和注释视图在键盘打开时同步滚动。