Reputation: 42670
In Java Swing, I can change the attributes of Font
relatively, without having to know its actual attributes. For example, I can say, I want to make this label's font 1 pixel less than its current size, without having to know what is current size.
private void initComponents() {
jLabel12.setFont(jLabel12.getFont().deriveFont(
jLabel12.getFont().getSize()-1f));
}
In Android, how I can achieve the similar stuff for TextView
?
Upvotes: 0
Views: 403
Reputation: 9023
TextView txtview=new TextView(this);
float fontSize = txtview.getTextSize();
txtview.setTextSize(fontSize-1.0f);
txtview.setText("this is test");
Upvotes: 2
Reputation: 1063
You can do it by using the same method :
TextView text = (TextView) findViewById(R.id.yourtextview);
float currentSize = text.getTextSize();
text.setTextSize(currentSize-1.0f);
Upvotes: 1