如何将省略号应用于实际的微调器而不是下拉视图?
How to apply ellipsis to the actual spinner instead of the dropdown views?
如何将省略号应用于微调器而不是下拉视图?当我搜索 spinner custom view
、spinner ellipsis
或 spinner long text
等术语时,我会在下拉列表中获得视图的结果。
例如:
- Spinner with long text not working fine
- How to wrap lengthy text in a spinner
- Spinner does not wrap text -- is this an Android bug?
- I have Spinner with some items, some of which have long text
这不是我要找的,我要找的是实际的微调器文本。
一张图片来说明我的问题
内容是 Recipe for disaster/Freeing king awowogei
但微调器试图将它放在下一行,这是我不想要的。相反,它应该在末尾添加省略号并显示 Recipe for disaster/Freeing king awo...
或其他内容。
微调器内容是从字符串数组和自定义适配器加载的,一切正常。
我试过添加
android:ellipsize="marquee"
android:singleLine="true"
到我的自定义下拉视图,但这不起作用。微调器没有关于文本换行的属性,所以我不知道如何实现这一点。
微调器的容器高度为 50dp,因为我不希望微调器高于该高度。
如果它与视图的简化 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>
将 android:ellipsize="end"
放在您在 SpinnerAdapter
中使用的 TextView
上(我假设是 quest_row.xml
)。
您的问题表明您尝试了 android:ellipsize="marquee"
,但这不会奏效,也不是您要查找的内容 ("it should add ellipsis at the end")。
如何将省略号应用于微调器而不是下拉视图?当我搜索 spinner custom view
、spinner ellipsis
或 spinner long text
等术语时,我会在下拉列表中获得视图的结果。
例如:
- Spinner with long text not working fine
- How to wrap lengthy text in a spinner
- Spinner does not wrap text -- is this an Android bug?
- I have Spinner with some items, some of which have long text
这不是我要找的,我要找的是实际的微调器文本。
一张图片来说明我的问题
内容是 Recipe for disaster/Freeing king awowogei
但微调器试图将它放在下一行,这是我不想要的。相反,它应该在末尾添加省略号并显示 Recipe for disaster/Freeing king awo...
或其他内容。
微调器内容是从字符串数组和自定义适配器加载的,一切正常。
我试过添加
android:ellipsize="marquee"
android:singleLine="true"
到我的自定义下拉视图,但这不起作用。微调器没有关于文本换行的属性,所以我不知道如何实现这一点。
微调器的容器高度为 50dp,因为我不希望微调器高于该高度。
如果它与视图的简化 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>
将 android:ellipsize="end"
放在您在 SpinnerAdapter
中使用的 TextView
上(我假设是 quest_row.xml
)。
您的问题表明您尝试了 android:ellipsize="marquee"
,但这不会奏效,也不是您要查找的内容 ("it should add ellipsis at the end")。