Reputation: 61
I need to set ellipsize=end
to TextView which is allowed to expand on two lines.
I've tried this code:
<TextView
android:id="@+id/carouselTitle"
android:layout_width="228dp"
android:layout_height="40dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="90dp"
android:layout_marginRight="0dp"
android:layout_marginTop="4.5dp"
android:ellipsize="end"
android:maxLines="2"
android:textSize="24sp"
android:textStyle="bold" >
</TextView>
Please reply with an example.
Upvotes: 4
Views: 5897
Reputation: 4510
This one will be work:
<TextView
android:id="@+id/carouselTitle"
android:layout_width="228dp"
android:layout_height="40dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="90dp"
android:layout_marginRight="0dp"
android:layout_marginTop="4.5dp"
android:ellipsize="end"
android:maxLines="2"
android:singleLine="false"
android:textSize="24sp"
android:textStyle="bold" >
</TextView>
The only thing you missed is android:singleLine="false"
.
And I recommend to put android:gravity="center_vertical"
for better UI. If the text just on one line, it will be center vertically.
Upvotes: 3
Reputation: 2403
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="false"
android:maxLines="2"
android:text="here is my text" />
Upvotes: 4