Adding custom widgets and GUI layout on top of PDFViewCtrl in my Android app

Skip to first unread message

Support

unread,
Jun 13, 2012, 7:30:34 PM6/13/12
to pdfne...@googlegroups.com
Q:
If I was using PDFViewCtrl class to display PDF in my Android app, is there any way I can modify the UI? Like adding buttons or textviews above and below the page image while retaining the ability to fling pages and zoom? I wasn't quite sure how to go about that or whether I'd have to just make a layout from scratch. 
 
-----------
A:  PDFViewCtrl is derived from android.view.ViewGroup. Therefore you can easily add a View on top of the page content by doing something like:

 

Button bt = new Button( PDFViewCtrl.getContext());

bt.layout(100, 100, 200, 200);

PDFViewCtrl.addView(bt);

 

You can also add a background image to PDFViewCtrl and this is illustrated in Samples\PDFViewCtrlDemo\src\com\pdftron\pdfnet\demo\pdfviewctrl\PDFViewCtrlDemo.java 

The sample code looks as follows:

                        /*

                        * if you want to set the background of PDFViewCtrl to a Drawable, you

                        * can first set its background to be transparent and then set the

                        * drawable.

                        */

                        //mPDFView.setClientBackgroundColor(255, 255, 255, true);

                        //Drawable draw = ...

                        //mPDFView.setBackgroundDrawable(draw);

Reply all
Reply to author
Forward
0 new messages