2014-09-07 6 views
1

안드로이드에서 epub boooks에 대해 FontSize의 가용성을 설정할 수 있습니까?android의 epubs에 대한 글꼴 크기는?

알림 : epub의 데이터를 WebView에 표시하고 있습니다.

세트 FontSize에 대한 옵션을 만들어야합니다.

public class MainActivity extends ActionBarActivity implements OnClickListener{ 
    WebView webView; 
    Handler hand ; 
    String data = null; 
    LinearLayout books; 
    int pagecount = 1; 
    int y = 1; 
    Book book; 
    @SuppressLint("SetJavaScriptEnabled") 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     hand = new Handler(); 
     webView = new WebView(this); 
     webView.getSettings().setJavaScriptEnabled(true); 
     books = (LinearLayout) findViewById(R.id.book); 
     AssetManager assetManager = getAssets(); 
     try{ 
      InputStream epubInputStream = assetManager.open("ok.epub"); 
      book = (new EpubReader()).readEpub(epubInputStream); 
      Log.i("Log_one", "author(s): " + book.getMetadata().getAuthors()); 
      Log.i("Log_two", "title: " + book.getTitle()); 
      Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage().getInputStream()); 
      Log.i("Log_three", "Coverimage is " + coverImage.getWidth() + " by " + coverImage.getHeight() + " pixels"); 
      logTableOfContents(book.getTableOfContents().getTocReferences(), 0); 

      Spine spine = book.getSpine(); 
      List<SpineReference> spineList = spine.getSpineReferences() ; 
      int count = spineList.size(); 

      String datas = new String(book.getContents().get(1).getData()); 
      webView.loadDataWithBaseURL("file:///android_asset/", datas, "text/html", "UTF-8", null); 
      books.addView(webView); 
      Log.i("Log_four", datas); 

     } 
     catch (IOException e) { 
       Log.e("Log_four", e.getMessage()); 
      } 

     webView.setOnTouchListener(new OnSwipeTouchListener(G.context){ 
       public void onSwipeTop() { 
        Toast.makeText(MainActivity.this, "top", Toast.LENGTH_SHORT).show(); 
       } 
       public void onSwipeRight() {  
        try { 

         books.removeAllViews(); 
         int i = pagecount + y; 
         y = i; 
          books = (LinearLayout) findViewById(R.id.book); 
          data = new String(book.getContents().get(y).getData()); 
          webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", null); 
          Log.i("test",String.valueOf(y)); 
          books.addView(webView); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
       } 
       public void onSwipeLeft() { 
        try { 
         if(y >= 1) 
         { 
          int i = y - pagecount; 
          y = i; 
         } 
         if(y >= 1) 
         { 
          books.removeAllViews(); 
          books = (LinearLayout) findViewById(R.id.book); 
          data = new String(book.getContents().get(y).getData()); 
          webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", null); 
          Log.i("test",String.valueOf(y)); 
          books.addView(webView); 
         }else if(y == 0) 
         { 
          Toast.makeText(getApplicationContext(), "Zero Page", Toast.LENGTH_LONG).show(); 
          Log.i("test",String.valueOf(y)); 
         } 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
       } 
       public void onSwipeBottom() { 
        Toast.makeText(MainActivity.this, "bottom", Toast.LENGTH_SHORT).show(); 
       } 

      public boolean onTouch(View v, MotionEvent event) { 
       gestureDetector.onTouchEvent(event); 
       return false; 
      } 
     }); 
    } 
     private void logTableOfContents(List<TOCReference> tocReferences, int depth) { 
      if (tocReferences == null) { 
       return; 
      } 
      for (TOCReference tocReference : tocReferences) { 
       StringBuilder tocString = new StringBuilder(); 
       for (int i = 0; i < depth; i++) { 
       tocString.append("\t"); 
       } 
       tocString.append(tocReference.getTitle()); 
       Log.i("Log_five", tocString.toString()); 
       logTableOfContents(tocReference.getChildren(), depth + 1); 
      } 
      } 
} 
+0

당신이 메릴랜드 압둘 Gafur @ .. 여기 –

+0

를 코드를 보여줍니다. 확인 –

답변

1

당신은 android webview의 글꼴 크기를 설정할 수 있습니다.

WebSettings webSettings = webView.getSettings(); 

setTextSize 또는

webSettings.setTextSize(WebSettings.TextSize.SMALLEST); 

이 하나가 너무 작동 중 : -

webSettings.setDefaultFontSize(10); 

감사

+0

고마워요. 아주 좋아. –