【问题标题】:Android Holo theme does not wrap multiple line spinner dropdown items [duplicate]Android Holo 主题不包含多行微调器下拉项 [重复]
【发布时间】:2012-10-25 15:51:41
【问题描述】:

我最近刚刚在我的 Android 应用中实现了全息主题。执行此操作后,我拥有的任何微调器(下拉项长多行)都不会将文本换行到多行。每个下拉项都保留在一行中,并被截断到一定长度。

这是我的微调器下拉资源的 xml

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none" />

这适用于 ICS 和 holo 主题之前的旧版本 android。

还有其他人遇到过这个问题吗?

【问题讨论】:

标签: android spinner android-spinner


【解决方案1】:

正如我在Spinner does not wrap text -- is this an Android bug?中提到的那样

我认为 android 存在错误。你可以试试这个。从文本中删除空格,然后显示它会正常工作。如果 textview 的长度是

使用示例代码将文件添加到名为 multiline_spinner_dropdown_item.xml 的 res/layout 文件夹:

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/sample_text"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="false"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee" />

当你创建微调器时,从这个布局创建它。

类似:

ArrayAdapter.createFromResource(this, items, R.layout.multiline_spinner_dropdown_item);

基本上,将android.R.layout.simple_spinner_dropdown_item布局复制到项目中,并通过在CheckedTextView中将singleLine属性设置为false来修改布局。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多