Android上的ListPopupWindow内的文本剪辑

Sha*_*ath 11 android

我在我的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();
Run Code Online (Sandbox Code Playgroud)

上面引用的布局的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" />
Run Code Online (Sandbox Code Playgroud)

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

谢谢..

dil*_*lix 4

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

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

您可以在此处此处找到示例。

您也可以在这里找到这个错误