xamarin.android - PDFTron 中的 CustomRelativeLayout Layout_with 和 layout_height 不起作用
问题描述
嗨,我在 Android Xamarin 项目的 PDFViewerCtrl 中有这个 CustomRelativeLayout:
<pdftron.PDF.Tools.CustomRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="250dp"
android:layout_height="250dp"
app:posX="50"
app:posY="150"
app:pageNum="1"
android:background="#33AFAFFF"
app:zoomWithParent="true">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_dark" />
</pdftron.PDF.Tools.CustomRelativeLayout>
位置 x=50 y=150 的 50*150 矩形。但我希望在页面位置 x=50 y=150 处绘制一个 250x250 的矩形。有什么我没有考虑或我做错了吗?我想扩展 RelativeLayout 以理想地匹配父 PDFPage。
谢谢。
解决方案
您可以将布局更新为
<pdftron.PDF.Tools.CustomRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="250dp"
android:layout_height="250dp"
android:id="@+id/container"
app:posX="50"
app:posY="150"
app:pageNum="1"
android:background="#33AFAFFF"
app:zoomWithParent="true">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_dark" />
</pdftron.PDF.Tools.CustomRelativeLayout>
然后,更新代码:
private void _pdfControl_DocumentLoad(object sender, System.EventArgs e)
{
var note = LayoutInflater.Inflate(Resource.Layout.pdf_custom_layout, _pdfControl);
var layout = note.FindViewById<CustomRelativeLayout>(Resource.Id.container);
layout.SetRect(_pdfControl, new pdftronprivate.PDF.Rect(50, 50, 300, 300), 1);
}
注意必须在页面坐标中指定所有点。
你会看见:
推荐阅读
- r - R::dplyr combine tibbles on matching columns and replace NA values
- numpy - 用于数据对象集合的布尔索引
- ms-word - 如何删除加载模板时添加的单词中的边框?
- editor - 可以将 VBA 用户表单代码拆分为多个文件(不同的 VBA 编辑器窗口)
- rust - 如何定义具有多个部分的对象,每个部分都包含对其他部分的引用
- python - 芹菜先进先出不使用python
- python - 如何将熊猫文本列转换为 nltk 文本对象
- python - 如何在python中更改字典的值?
- firebase - Algolia 不使用 Svelte 返回结果。我究竟做错了什么?
- r - 使用 R 中的 `survey` 包来估计重叠域之间的协方差