1

I am trying to create a single line text input in Jetpack Compose.

Since this input should have a fix width of 200.dp and is only one line, longer text is going to be cut off. Sometimes it looks like the cut off text does not even exist because the cut is made between two letters. In order to show the user that there is "more" text already typed I would prefer an ellipsis (e.g. This is a sample inpu...) effect.

I tried to use the default TextField and BasicTextField composables but there seems to be no easy solution.

Is there a way to create this ellipsis effect in Jetpack Compose?

oldu
  • 113
  • 1
  • 7
  • Does this answer your question? [How to show ellipsis (three dots) at the end of a Text line in Android Jetpack Compose?](https://stackoverflow.com/questions/65736375/how-to-show-ellipsis-three-dots-at-the-end-of-a-text-line-in-android-jetpack-c) – Björn Kechel Apr 11 '22 at 13:44
  • @BjörnKechel I am afraid not. I need an editable text input like EditText in the old view-based system. Unfortunately the composables TextField/BasicTextField do not have an attribute 'overflow'. – oldu Apr 11 '22 at 13:49
  • Could you explain what you meant by the old view-based system? – Aryan3212 Apr 11 '22 at 15:29
  • 1
    I do not think that an EditText allows ellipsis, usually they end up horizontally scrollable – Björn Kechel Apr 11 '22 at 15:36
  • @Aryan3212 I meant the UI-Framework used before Jetpack Compose – oldu Apr 11 '22 at 16:10
  • @BjörnKechel Oh I did not know that. However I would appreciate an ellipsis behaviour in Compose. – oldu Apr 11 '22 at 16:11
  • Meanwhile you can set the `singleline` property as true, in that case the text would become scrollable. – Aman Verma Mar 28 '23 at 11:12

0 Answers0