【问题标题】:Text clipping inside ListPopupWindow on AndroidAndroid 上 ListPopupWindow 内的文本剪辑
【发布时间】:2013-11-29 04:29:44
【问题描述】:

我的 Android 应用程序中定义了一个 ListPopupWindow,如下所示。

    ListPopupWindow listPopupWindow;

    listPopupWindow = new ListPopupWindow(RootView.this);
    listPopupWindow.setAdapter(new ArrayAdapter<String>(RootView.this,
            R.layout.push_list_item, pushMessages));
    listPopupWindow.setAnchorView(bEvents);
    listPopupWindow.setWidth(300);
    listPopupWindow.setHeight(400);
    listPopupWindow.setModal(true);
    listPopupWindow.show();

上面引用的布局的 XML 如下所示..

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#FF0000"
    android:paddingLeft="6dp"
    android:textSize="12sp"
    android:maxLines="3"
    android:lines="3"
    android:ellipsize="end"
    android:textStyle="bold" />

当我得到一个更大的文本时,文本似乎只是剪裁而不是换行,即使我在 XML 中指定了正确的属性。任何人都可以帮助我了解这里发生了什么,并为我的问题提出解决方案。

谢谢..

【问题讨论】:

标签: android


【解决方案1】:

您的 xml 文件应该遇到的主要问题是不可能有 >2 行 + 椭圆大小。

你应该实现你自己的EllipsizeTextView 来支持真正的多行椭圆文本视图。

您可以找到herehere 的示例。

你也可以找到这个bug here

【讨论】:

    猜你喜欢
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 1970-01-01
    相关资源
    最近更新 更多