In the application that I am developing, there exists a toggle button for a particular option. I have utilized a single XML file to cater for all display sizes. The tab displays this screen accurately. Nonetheless, on smaller screens, the toggle overlaps with the text view within the same horizontal line. It is impractical to reduce the text size of this button from the layout as it will also decrease the text size of the tab, and there are other buttons on this screen that display correctly. The text view in question is longer compared to the other text views.
Therefore, I have included code within my fragment to reduce the text sizes of this button exclusively on phones, by verifying the isSmallPortrait resource value. However, I am apprehensive that these modifications could affect the performance of the application. Is this the best approach to carry out such tasks? Are there any other best practices to accomplish this objective? (This fragment is 500 codes long)
textDisplayLastViewed = getView().findViewById(R.id.textDisplayLastViewed);
if(!getResources().getBoolean(R.bool.isSmallPortrait)){
}
else{
textDisplayLastViewed.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
}