What's the best way to limit text length of EditText in Android

后端 未结 22 2104
囚心锁ツ
囚心锁ツ 2020-11-22 13:33

What\'s the best way to limit the text length of an EditText in Android?

Is there a way to do this via xml?

22条回答
  •  余生分开走
    2020-11-22 14:35

    From material.io, you can use TextInputEditText combined with TextInputLayout:

    
    
        
    
    
    

    You can configure a password EditText with drawable:

    Or you can limit text length with/without a counter:

    Dependency:

    implementation 'com.google.android.material:material:1.1.0-alpha02'
    

提交回复
热议问题