Created
August 29, 2018 02:29
-
-
Save ramseth001/fdc2bbcc3846e8b078afe9b93044045d to your computer and use it in GitHub Desktop.
Create TextView programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function customizes the header of the tab | |
* | |
* @param tabName Name of the tab | |
* @return TextView -> header of the tab | |
*/ | |
private TextView getTabHeader(int tabName) { | |
TextView textView = new TextView(this); | |
textView.setText(tabName); | |
textView.setGravity(Gravity.CENTER); | |
textView.setTextColor(getResources().getColor(R.color.colorText)); | |
Typeface face; | |
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { | |
face = getResources().getFont(R.font.karla); | |
} else { | |
face = ResourcesCompat.getFont(getApplicationContext(), R.font.karla); | |
} | |
textView.setTypeface(face); | |
textView.setTypeface(textView.getTypeface(), Typeface.BOLD); | |
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen._16sp)); | |
return textView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment