android - 如何设置长文本只显示2行并附加

标签 android textview

<分区>

Possible Duplicate:
android - line break in TextView

<TextView 
    android:text="Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee."

    android:id="@+id/txtDesc"
    android:maxLines="3" 
    android:lines="3"
    android:ellipsize="end"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/>

我这样试过,但最后只显示 1 行 ...

如何将它设置为显示 2 行...

如果我使用 android:ellipsize="marquee"instread 它不会显示 ... 最后只显示 1 行

最佳答案

您可以使用两个 TextView。在一个 TextView 中显示部分文本,在第二个 TextView 中使用以下代码。 我认为椭圆会在一行中显示数据,然后省略。如果你使用椭圆我不认为你可以在 TextView 中获得两行数据。这就是为什么我建议您使用两个 TextView。在最后一个 TextView 使用椭圆

<TextView 
    android:text="Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are one of the UK�s leading retailers, with over 21 million people visiting our stores each week. We offer stylish, high quality, great value clothing and home products, as well as outstanding quality foods, responsibly sourced from around 2,000 suppliers globally. We employ over 75,000 people in the UK and abroad, and have over 600 UK stores, plus an expanding international business. We are the number one provider of womenswear and lingerie in the UK, and are rapidly growing our market share in menswear, kidswear and home, due in part to our growing online business. Overall, our clothing and homeware sales account for 49% of our business. The other 51% of our business is in food, where we sell everything from fresh produce and groceries, to partly-prepared meals and ready meals. Now more than ever, we�re also known for our green credentials as a result of our five-year eco plan, Plan A, which will see us, amongst other things, become carbon neutral and send no waste to landfill by 2012."
    android:id="@+id/txtDesc"
    android:maxLines="3" 
    android:lines="3"
    android:ellipsize="end"
    android:layout_width="100dip" 
    android:layout_height="wrap_content"/>

谢谢 迪帕克

关于android - 如何设置长文本只显示2行并附加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6338941/

相关文章:

android - 嵌入线性布局的 Webview 不会上下滚动,只能左右滚动

android - 使用 WRAP_CONTENT LayoutParams 使 TextView 文本适合一行

android - 是否可以在android的textview中垂直书写?

android studio 1.5.1,棉花糖未检测到互联网访问不会自动重新连接

android - 函数在 android 中返回负值,但在 flutter 应用程序中的 web 上返回正值

java - 如何滚动到给定的行号,ScrollView 中的 TextView

java - Android Studio - ImageView下方的TextView

android - 在 Cloud Firestore 中更新集合名称

android - 将应用内结算版本 2 迁移到版本 3 的最佳方法是什么?

android - 使用 com.facebook.widget.LoginButton 时 android 布局出错