title: Ebook reader pagination issue in android
body: <p>I am creating an ebook reader for android. I got problems when the content is broken in to pages.</p>
  <p>Here are 3 screenshots of my app.</p>
  <p><img src="https://i.stack.imgur.com/rEHjl.png" alt="enter image description here" />
  <img src="https://i.stack.imgur.com/4qQ2h.png" alt="enter image description here" />
  <img src="https://i.stack.imgur.com/LS9uE.png" alt="enter image description here" /></p>
  <p><strong>As you can see the content is not perfectly fit to the screen.</strong> For example the last sentence should have been completed on the first image without jumping onto the next page. Also the image of the third pic should have come to the latter part of the second image since there is enough space. <strong>In some pages the content goes underneath the navigation bar as well.</strong></p>
  <p>The logic is : I get the entire content and when a space is found get the previous word and then check whether the text height is larger than the screen height. If not again check for the next space and append the next word to the previously collected string. Likewise I get the page content.</p>
  <p>The code to get the textHeight is as follows,</p>
  <pre><code>    public int getTextHeight(final String text) {
       TextView textView = new TextView(getContext());
       textView.setText(text);
       textView.setTextSize(TEXT_SIZE);
       TextPaint textPaint = textView.getPaint();
       return new StaticLayout(text.toString(), textPaint, getScreenWidth(),Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true).getHeight();
      }
  </code></pre>
  <p>Code for Screen height ,</p>
  <pre><code>    public int getScreenHeight() {
        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        return dm.heightPixels;
      }    
  </code></pre>
  <p>** Since there is a navigation bar at the bottom I reduced 50 pixels from the screen height. But still the content goes underneath the navigation bar.</p>
  <p>So my questions are,</p>
  <ol>
  <li>How to hide the navigation bar or If it can not be hidden then how to get the exact height of it</li>
  <li>What is the reason for the content not to fit on the screen, I really can't find the reason for this. (I checked with a ebook that has only text, there are some white space at the bottom, but didn't go underneath the bar)</li>
  </ol>
  <p>**I put 300 px height for images. Used ViewPager for implementation.</p>
  <p>Thanks.</p>