Code for Opening PDF in Single Page View and Hiding Controls in Android App

To open a PDF in single page view and hide all controls in an Android app, you can use the PDFViewer library, which provides various functionalities for working with PDF files. Here’s an example code snippet that demonstrates how to achieve this:

First, add the PDFViewer library to your project by including the following line in your app-level build.gradle file:

     implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

Next, create a layout file (e.g., activity_pdf_viewer.xml) that contains the PDF viewer component:

<RelativeLayout xmlns:android=""

        android:layout_height="match_parent" />

Then, in your activity class, load the PDF file, enable single page view, and hide the controls:

import android.os.Bundle;
import com.github.barteksc.pdfviewer.PDFView;

public class PDFViewerActivity extends AppCompatActivity {

    private PDFView pdfView;

    protected void onCreate(Bundle savedInstanceState) {

        pdfView = findViewById(;

        // Load the PDF file from assets folder

Make sure to replace "your_pdf_file.pdf" with the actual name and location of your PDF file in the assets folder.

This code will load the PDF file, display it in single page view, and hide all the controls, such as page navigation buttons and zoom controls. You can further customize the PDF viewer’s behavior by modifying the options passed to the PDFView object.

Remember to add the necessary permissions in your AndroidManifest.xml file to read files from the assets folder if you haven’t already done so:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Note: It’s important to handle exceptions and provide appropriate error handling when working with external files or resources.