-1

When you rotate the screen while reading, it reloads to page 0.

I want it to stay where I read.

Something else:

When the screen is rotated horizontally, the display is fully displayed, but it can be zoomed out.

I want to disable it zoomed out.

pdfView.fromAsset(""+link).onRender(new OnRenderListener()
{
    @Override
    public void onInitiallyRendered(int nbPages, float pageWidth, float pageHeight)
    {
        pdfView.fitToWidth();
                }
    }).load();
}
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
Safaa Hj
  • 1
  • 1
  • What do you mean by "codes not accepted"? Do you get an error? If so, post the logcat. Also, what you have tried so far? Indicate your attempts to resolve the issue. – David Lee Jul 06 '21 at 10:49
  • This doesn't help us. Plus you need to learn how to ask questions first. https://stackoverflow.com/help/how-to-ask – Anirudhdhsinh Jadeja Jul 06 '21 at 10:56

1 Answers1

1

When you rotate your screen, the current activity recreates itself. You can save the current page number on onSaveInstanceState() then you can retrieve it in onRestoreInstanceState() method.

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putInt("currentPageNumber", pageNumber);
    
    // call superclass to save any view hierarchy
    super.onSaveInstanceState(outState);
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    int pageNumber = savedInstanceState.getInt("currentPageNumberKey"));
}
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
Baki Kocak
  • 389
  • 1
  • 9
  • This code didn't work for me or maybe I didn't know how to use it. The {pageNumber} is red and is not corrected – Safaa Hj Jul 06 '21 at 11:29