代码之家  ›  专栏  ›  技术社区  ›  Denny

如何将省略号应用于实际微调器而不是下拉视图?

  •  0
  • Denny  · 技术社区  · 7 年前

    如何将省略号应用于微调器而不是下拉视图?当我搜索诸如 spinner custom view , spinner ellipsis spinner long text 我在下拉列表中得到视图的结果。 例如:

    一张图片来说明我的问题

    enter image description here

    内容是 Recipe for disaster/Freeing king awowogei 但是微调器试图把它放在下一行,这是我不想要的。相反,它应该在末尾添加省略号并显示 Recipe for disaster/Freeing king awo... 或者别的什么。

    微调器内容是从一个字符串数组和一个自定义适配器加载的,所有这些都可以正常工作。

    我试着添加

    android:ellipsize="marquee"
    android:singleLine="true"
    

    我的自定义下拉视图,但这不起作用。微调器没有关于文本包装的属性,因此我无法找到如何实现这一点。

    如果它与视图的简化xml代码相关

    quest_row.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/input_background_color"
        android:orientation="horizontal"
        android:padding="5dp">
    
        <TextView
            android:id="@+id/quest_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:textColor="@color/text"
            android:textSize="18sp"/>
    </LinearLayout>
    

    quest.xml 主要布局

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">
    
        <Spinner
            android:id="@+id/quest_selector_spinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:dropDownWidth="wrap_content"
            android:padding="5dp"/>
    </LinearLayout>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   CommonsWare    7 年前

    android:ellipsize="end" TextView SpinnerAdapter ( quest_row.xml

    android:ellipsize="marquee" ,这将不起作用,也不是你要找的东西(“它应该在末尾添加省略号”)。