Joshua Rogers
Joshua Rogers

Reputation: 3558

CustomRelativeLayout Layout_with and layout_height in PDFTron not working

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: enter image description here

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.

Upvotes: 1

Views: 81

Answers (1)

Shirley G
Shirley G

Reputation: 372

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:

enter image description here

Upvotes: 1

Related Questions