【问题标题】:3 TextView's with ellipsize="middle"3 个带有 ellipsize="middle" 的 TextView
【发布时间】:2011-12-15 00:23:58
【问题描述】:

我想要一个带有 3 个文本视图的线性布局。
文本 1:abcdefghijklmn
文本 2:-
正文 3:nmlkjihgfedcba

它应该看起来像:

/-----------------------\
| abc...lmn - nml...cba |
\-----------------------/

当文本 1 较短时,“abc”,则应如下所示:

/-----------------------\
| abc - nmlkji...fedcba |
\-----------------------/

我无法让它工作。使用重量,但“-”始终位于中间。
有什么想法吗?

【问题讨论】:

  • 查看我当前的(最佳)代码:pastebin.com/UAmGq5if 获取完整代码,imagepaste.nullnetwork.net/viewimage.php?id=2934 获取图片。但它仍然不起作用,这里第一个不是椭圆的

标签: android textview


【解决方案1】:

这应该可行。 weight 正是你不应该在这里使用的东西。除非我在这里遗漏了一些明显的东西!

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="abcdefghijklmn"/>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:text="-"/>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="nmlkjihgfedcba"/>
</LinearLayout>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-31
  • 2012-06-30
  • 1970-01-01
  • 2021-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多