Increasing And Decreasing The Font Sizes Of The Android Application By User Selection
Actually i want to specify the custom text size in my application by user selection. Below is a figure that demonstrate the idea/theme  So, for that i have an idea to achieve this.
Solution 1:
you can check
btnTextDeSave.setOnClickListener(onClickEven);
btnTextInSave.setOnClickListener(onClickEven);
publicOnClickListeneronClickEven=newOnClickListener() {
    @OverridepublicvoidonClick(View v) {
        // TODO Auto-generated method stubswitch (v.getId()) {
            break;
        case R.id.btTextDeSave:
            txtDescriptionSave.setTextSize(TypedValue.COMPLEX_UNIT_PX, (txtDescriptionSave.getTextSize() - 2f));
            break;
        case R.id.btTextInSave:
            txtDescriptionSave.setTextSize(TypedValue.COMPLEX_UNIT_PX, (txtDescriptionSave.getTextSize() + 2f));
            break;
        default:
            break;
        }
    }
};
Solution 2:
To increase the size of your textView you can use 
_percentField.setTextSize(values[0]*2);
where values is an array.
And to decrease you can try
 _percentField.setTextSize(values[0]/2);
Solution 3:
You can try this-
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, <font-size value in integer> );
    // to update your changes
    textView.invalidate();
Solution 4:
do it this way
float fs = prefs.getFloat("fontsize", 12);
seekbar.setProgress((int)fs);
layout.setTextSize(TypedValue.COMPLEX_UNIT_PX,seekbar.getProgress());
and don't forget onProgressChanged:
layout.setTextSize(TypedValue.COMPLEX_UNIT_PX,progress);
Solution 5:
You can do this simply by:
//Adjust values with whatever your need isintSIZE_LARGE=24; 
int SIZE_SMALL= 16;
btnLargeText.setOnClickListener(newOnClickListener() {
    
    @OverridepublicvoidonClick(View arg0) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, LARGE_SIZE);
    }
});
btnSmallText.setOnClickListener(newOnClickListener() {
    
    @OverridepublicvoidonClick(View arg0) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, SIZE_SMALL);
    }
});
Post a Comment for "Increasing And Decreasing The Font Sizes Of The Android Application By User Selection"