Jaswant
Jaswant

Reputation: 1

How do I increase the size of a TextView when the user clicks a button?

How do I increase the size of a TextView when the user clicks a button?

Upvotes: 0

Views: 761

Answers (3)

Karan_Rana
Karan_Rana

Reputation: 2823

Use the following piece of code inside the on click method

yourtextview.setTextSize(TypedValue.COMPLEX_UNIT_SP,14);

give it a try and see if it works.

Upvotes: 2

Adnan Mulla
Adnan Mulla

Reputation: 2866

I would probably go about doing this by using the TextView size property.

In the onClick of the button, you could call the setTextSize(int,float) property to increase or decrease the size.

You would probably need a variable as well to increment the size based on the value & then after the variable becomes 5 you could reduce the size back to the original size

Hope this helps.

Upvotes: 0

May_I_HelpYou
May_I_HelpYou

Reputation: 1

public class Zoom extends Activity
{
private String productName;

public void onCreate(Bundle savedInstanceState)
 {

        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.zoom);

        Intent intent = getIntent();
        productName = intent.getStringExtra("ChoosenMed");

        TextView productNameTextView=(TextView)findViewById(R.id.prodcutNameZoomTextView);
  productNameTextView.setText(productName);

 }
}

Upvotes: -1

Related Questions