PDFTron中的CustomRelativeLayout Layout_with和layout_height不起作用 [英] CustomRelativeLayout Layout_with and layout_height in PDFTron not working
问题描述
我在Android Xamarin项目的PDFViewerCtrl中拥有这个CustomRelativeLayout:
Hi I have this CustomRelativeLayout in a PDFViewerCtrl in an Android Xamarin project:
<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>
渲染后,我会看到以下内容:
When it gets rendered I see this:
在pos x = 50 y = 150中的50 * 150矩形.但是我希望在页面位置x = 50 y = 150处绘制250x250矩形.有什么我不考虑的或做错了吗?我想扩展RelativeLayout以理想地匹配父PDFPage.
A 50*150 rectangle in pos x=50 y=150. But what I'd expect is to draw a 250x250 rectangle at page position x=50 y=150. Is there anything I'm not considering or I'm doing wrong? I'd like to expand the RelativeLayout to match the Parent PDFPage ideally.
谢谢.
推荐答案
您可以将布局更新为
<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);
}
请注意,所有点都必须在页面坐标中指定.
Note all points must be specified in page coordinate.
您将看到:
这篇关于PDFTron中的CustomRelativeLayout Layout_with和layout_height不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!