Skip to content

Instantly share code, notes, and snippets.

@dharmakshetri
Created September 24, 2017 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharmakshetri/e83d6f0e371e6579e4eb7c070e248341 to your computer and use it in GitHub Desktop.
Save dharmakshetri/e83d6f0e371e6579e4eb7c070e248341 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Autosizing from programmatically
//configure uniform autosize
textview.setAutoSizeTextTypeWithDefaults(TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM)
// via support library
TextViewCompat.setAutoSizeTextTypeWithDefaults(textview,TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
//set properties of textview
textview.setAutoSizeTextTypeUniformWithConfiguration(12,100,2,2)
// via support library
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(textview,12,100,2,2)
//set preset sizes
val presetSize:IntArray = intArrayOf(10,12,30,40,100)
textview.setAutoSizeTextTypeUniformWithPresetSizes(presetSize,2)
// via support library
TextViewCompat.setAutoSizeTextTypeUniformWithPresetSizes(textview,presetSize,2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment