Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

I want to reset zoom when changing orientation 7 years 5 months ago #11362

  • app2U
  • app2U's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 12
  • Thank you received: 0
Hello,
I'm trying to reset the zoom (full screen size) when changing the orientation. When I change the orientation from portrait to landscape, the zoom remains the same, and if the page was full screen in portrait mode, it's zoomed in landscape mode. (The other way around, landscape -> portrait, works as I want).

Example:
when i change the orientation.. :

what I want to see (full screen):


Does a function exist to reset the zoom to fit the page to full screen? How can I do what I'm trying to achieve?
I also want to remain in the same page, so I also tried to reset the activity but it returns the pdf to the first page.

Thank you.
Last edit: by app2U.
The topic has been locked.

I want to reset zoom when changing orientation 7 years 5 months ago #11369

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
I suggest you to set zoom to min level using vZoomSet and vGetMinScale() (to get min scale) in onConfigurationChanged method of PDFViewAct.
The topic has been locked.

I want to reset zoom when changing orientation 7 years 5 months ago #11381

  • app2U
  • app2U's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 12
  • Thank you received: 0
I'm trying this implementation and it is not working:
@Override
    public void onConfigurationChanged(Configuration newConfig)
    {
		super.onConfigurationChanged(newConfig);

		PDFLayout.PDFPos pdfPos = m_view.m_layout.vGetPos(0,0);
		float minScale = m_view.m_layout.vGetMinScale();
		m_view.m_layout.vZoomSet(m_view.m_layout.vGetX(), m_view.m_layout.vGetY(), pdfPos, minScale);

    }

I have set m_layout from "PDFLayoutView" class to public in order to acces it.
What should I do in order to make it work?
The topic has been locked.

I want to reset zoom when changing orientation 7 years 5 months ago #11382

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
as a better implementation you can do as following in PDFLayoutView
@Override
	protected void onSizeChanged( int w, int h, int oldw, int oldh )
	{
		super.onSizeChanged(w,h,oldw, oldh);
		if(m_layout != null && m_status != STA_ANNOT && w > 0 && h > 0)
		{
			m_layout.vResize(w, h);

			//new code
			PDFLayout.PDFPos pdfPos = m_layout.vGetPos(0,0);
			m_layout.vZoomSet(m_layout.vGetWidth()/2, m_layout.vGetHeight()/2, pdfPos, 1);
                        PDFGotoPage(m_pageno);

			if( m_goto_pos != null )
			{
				m_layout.vSetPos(0, 0, m_goto_pos);
				m_goto_pos = null;
				invalidate();
			}
		}
	}

This implementation resets the view scale even if you are in zoom state.
Last edit: by Davide.
The topic has been locked.
  • Page:
  • 1
Powered by Kunena Forum