CustomRelativeLayout Layout_with and layout_height in PDFTron not working

眉间皱痕 提交于 2020-03-23 07:49:20

问题


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:

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.

Thanks.


回答1:


You can update your layout to

<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>

Then, update code:

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.

You will see:



来源:https://stackoverflow.com/questions/60736322/customrelativelayout-layout-with-and-layout-height-in-pdftron-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!