Android的全息主题不换多行微调下拉项 [英] Android Holo theme does not wrap multiple line spinner dropdown items

查看:131
本文介绍了Android的全息主题不换多行微调下拉项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近刚刚实施了全息主题在我的Andr​​oid应用程序。这样做了以后,任何微调,我有,在下拉产品多线长,也不会自动换行到多行。每个下拉项保持全部在一行,并截断到一定长度。

I recently just implemented the holo theme into my android app. After doing this, any spinner that I have, where the drop down item is multiple lines long, will not wrap the text to multiple lines. Each drop down item is kept all on one line and truncated to a certain length.

下面是我的XML的下拉资源微调

Here is my xml for the drop down resource for the spinner

<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之前老版本和全息主题。

This works on older versions of android before ICS and the holo theme.

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

Has anyone else encountered this issue?

推荐答案

正如我所提到的:<一href="http://stackoverflow.com/questions/14139106/spinner-does-not-wrap-text-is-this-an-android-bug/14392369#14392369">Spinner不换行文字 - 这是一个Android的bug

我觉得这是一个错误的机器人。你可以试试这个。删除从文本的空间,然后显示它会正常工作。如果TextView中的长度为&lt;该字符串,它忽略了空格后的所有字符。对于一个解决方法,你可以试试这个:

I think there is a bug on android. You could try this. Remove the spaces from the text and then display it would work fine. If the length of the textview is < that of the string, it ignores all the characters after the space. For a work-around you could try this :

将文件添加到与样品code名为multiline_spinner_dropdown_item.xml RES /布局文件夹:

add a file to res/layout folder named multiline_spinner_dropdown_item.xml with the sample code:

<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" />

和从这种布局,当你创建的微调创建它。

and when you are creating the spinner create it from this layout.

是这样的:

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

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

Basically, copy the android.R.layout.simple_spinner_dropdown_item layout into the project and modify the layout by setting singleLine attribute to false in CheckedTextView.

这篇关于Android的全息主题不换多行微调下拉项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆