Created
August 7, 2014 08:02
-
-
Save j-onathan/677cb9d443fb029b2f50 to your computer and use it in GitHub Desktop.
Android Code Example: TextView (from https://www.codota.com/android/scenarios/52fcbdc9da0a1c68922cac4a/android.widget.TextView?tag=dragonfly)
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
TextView textView = (TextView)row.findViewById(android.R.id.text1); | |
float scale = activity.getResources().getDisplayMetrics().density; | |
boolean leftPadding = (parent.getTag().equals("right")); | |
boolean topPadding = (position == 0); | |
textView.setPadding((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(20 * scale) * (!leftPadding && topPadding ? 1 : 0), (int)(20 * scale), 0); | |
textView.setText(item); | |
textView.setTextColor(Color.BLACK); | |
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment