I am sharing an example where I have set maxLength=1 i.e. limit it to a single line with maxLines attribute, then use the ellipsize=end to add a "..." automatically to the end of any line that has been cut-off.
Please Note: layout_width which is 120dp i.e. after 120dp any text
exceeding will triggrer "ellipsize=end" property
paste the below code directly to check.
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:maxLength="40"
android:text="Can I limit TextView's number of characters?"
android:textColor="@color/black"
android:textSize="12sp"
android:textStyle="bold" />
.