, XML . .
:
<style name="MyTvStyle">
<item name="android:textSize">40sp</item>
</style>
:
<TextView style="@style/MyTvStyle" ... />
. TextViews android:id, findViewById.
:
int[] id_array = {
R.id.textview1, R.id.textview2, R.id.textview3
}
for(int i : id_array) {
TextView textview = (TextView)findViewById(i);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,40);
}
And yes, it is always better to use spinstead of the usual pixel values. Because it spwill scale with the size of the device and user settings.
source
share