i have a home screen with header and footer and in between i have ten rows of text to display. the text size is hard coded in java but when i run the app the footer gets stretched to adjust with the text size fixed. but it looks odd when it gets stretched. is there a way to assign the text size dynamically based on the screen. please help me with this, if you could look at the image you will understand the footer problem.
if (dpiClassification == DisplayMetrics.DENSITY_HIGH) {
if (isTablet) {
textSize = (int) (((d.getHeight() - (totImageHeight)) / 10) - (25 * dm.density));
} else {
textSize = (int) (((d.getHeight() - (totImageHeight)) / 10) - (11 * dm.density));
}
} else if (dpiClassification == DisplayMetrics.DENSITY_MEDIUM) {
if (isTablet) {
textSize = 90;// (int) (((d.getHeight() - (totImageHeight)) /
// 10) - (15 * dm.density));
} else {
textSize = (int) (((d.getHeight() - (totImageHeight)) / 10));
}
} else {
textSize = (int) (((d.getHeight() - (totImageHeight)) / 10));
}
Try to set your text size in DP and dynamically convert DP to PX and put this PX values in
To convert I use next Code:
Hope it help you!