user2182071
user2182071

Reputation: 35

textview increase and decrease in android webview

I have to develop one Android application. Here I have to increase and decrease the TextView text size.

I have to click two ImageView (positive and negative).

First, I have to click the positive image which means I have to increase the text size by 3 times afterthat have to disable the positive image. Secondly, I have to click the negative image which means I have to decrease the text size by 5 times afterthat have to disable the negative image.

Third, now I have to click the negative image directly without click the positive image which means I have to decrease the text size by 2 times and the negative image is disabled. How can I develop these?

My current situation is looking like :

First, I have to click positive image means increasing the value 3 times. The image isn't disabled. Please tell me how I can disable the positve image. Second I have to click the negative image which means decreasing the text size 5 times.

Third I have to click the negative image directly without click the positive image which means the text size is not decreasing? How can I resolve these problems?

int text_size=16;int text_max;
   int text_min=12;
String fullcontent = in.getStringExtra("FullContent");
content.loadDataWithBaseURL(null,fullcontent, "text/html", "UTF-8",null);
positive = (ImageView) findViewById(R.id.imageView3);
positive.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
       if (text_size < 22) {
           content.getSettings().setDefaultFontSize(text_size += 1);
         text_max=  text_size++;
            j = text_max;      
     if (j == text_max)
    {
        positive = (ImageView) findViewById(R.id.imageView3);
        positive.setEnabled(false);
    }   
         }
   }  
});   

negative = (ImageView) findViewById(R.id.imageView4);
negative.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      if (j > 12)
  {
      //Description.FontSize -= 2;
   content.getSettings().setDefaultFontSize(j -= 1);
   int k=   j--;
   text_min = k;
      if (text_size == j)
      {
          negative = (ImageView) findViewById(R.id.imageView4);
          negative.setEnabled(false);
      }  
    }
      }  
});   

EDIT:

Initially i have declared the text_default,text_max,text_min size like :

int text_size=16;
int text_max=22;
int text_min=10;

I have to write the condition for increase the fontsize maximum while clikcing positive image:

 positive = (ImageView) findViewById(R.id.imageView3);
 positive.setOnClickListener(new OnClickListener() {
 public void onClick(View v) {
 if (text_size < 22)
 {
    content.getSettings().setDefaultFontSize(text_size += 1);
    text_max=  text_size++;
    j = text_max;
    }} });

I have wrote the condition for decrease the textSize while clicking negative image:

negative = (ImageView) findViewById(R.id.imageView4);
negative.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
 if (j > 10)
  {
   content.getSettings().setDefaultFontSize(j -= 1);
   int k=   j--;
   text_min = k;
    }} });

Now i have to run the application and directly click the positive image means the textsize will be increase 3 times.after that i have to click the negative image means the textsize will be decrease the 5 times.its worked well...

But i have to run the application and directly click the negative image means the textsize will be decrease the textsize 3 times like bbc news reader application(A+,A- functionality).

How can i do ??? please give me some idea to develop ???

Upvotes: 1

Views: 574

Answers (1)

lokoko
lokoko

Reputation: 5803

Try something like this :

At the start get a handle to the textView's textSize.

float textSize = textView.getTextSize();
if (//Check if first time) {

    textView.setTextSize(textView.getTextSize() * 3f);

or

    textView.setTextSize(textView.getTextSize() / 3f);
}
else {
    textView.setTextSize(textView.getTextSize() * 5f);

or

    textView.setTextSize(textView.getTextSize() / 5f);
}

Upvotes: 0

Related Questions