Note that there are some explanatory texts on larger screens.

plurals
  1. POText size not decreasing
    text
    copied!<p>I'm working on rendering a text on textview. I'm trying to add two buttons to zoom in and out the text inside text view and the code goes like this</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chapter_view); String chapter; chapter=getIntent().getExtras().getString("ChapterName"); final StringBuffer buffer = new StringBuffer(); int id= getResources().getIdentifier(chapter,"raw",getPackageName()); try{ DataInputStream dataIO= new DataInputStream(getResources().openRawResource(id)); String strLine= null; while((strLine = dataIO.readLine())!=null){ buffer.append(strLine); buffer.append("\n"); } dataIO.close(); }catch(Exception e){ } final TextView tv=(TextView) findViewById(R.id.chapter); tv.setText(buffer.toString()); Button zoomIn = (Button) findViewById(R.id.zoomin); zoomIn.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub textSize = tv.getTextSize(); tv.setTextSize((float) (textSize+0.25)); } }); Button zoomOut = (Button) findViewById(R.id.zoomout); zoomOut.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub textSize = tv.getTextSize(); tv.setTextSize((float) (textSize-0.25)); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.chapter_view, menu); return true; } } </code></pre> <p>But the problem I'm getting is the even upon clicking zoom out button, it still increasing the font size of the text. Please help me out in this. Also once I close one chapter and opens another, the text size will reset to its default value. Are there any solutions regarding this. I'm thinking of using the namevalue pair for this solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload