I want to limit the amount of space a TextView can take in the screen with the following rules:
Here go some screenshots explaining valid and invalid results:
Short Text:
Medium Text:
Internal Scroll:
Blank spaces:
Excessive length:
Try like this.
XML
<TextView
android:id="@+id/descTxtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="5"
android:scrollbars="vertical"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s."
android:textColor="#232e3b"
android:typeface="sans" />
in JAVA
descTxtView= (TextView) findViewById(R.id.descTxtView);
descTxtView.setMovementMethod(new ScrollingMovementMethod());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With