Spinner não envolve text – isso é um bug do Android?

Se o text de um item Spinner for muito longo paira se encheckboxr em uma única linha, o text não está embrulhado, mas é cortado. Este é apenas o caso do nível da API> = 11 . Aqui estão as capturas de canvas do Android 4.2.2 (à esquerda), que mostra o comportamento errado e o Android 2.3.3 (à direita), onde pairece ser o esperado.

  • Objeto compairtilhado nested não lendo
  • Spinner não se aplica atributo dropDownSelector
  • Emulador paira Android 4.4 KitKat não está começando
  • Android - a input html perde o foco quando o keyboard suave é aberto (ASP.net)
  • Como o tratamento de erros é feito no Retrofit 2? Não consigo encontrair a class RetrofitError que a maioria das soluções sugere?
  • NetworkOnMainThread
  • android:singleLine="false" simplesmente é ignorado aqui. Então, como todas as outras tentativas, como o android:lines , android:minLines , etc. O TextView pairece ser muito mais amplo do que a lairgura da window.

    Vi outras pessoas com o mesmo problema, mas ninguém conseguiu encontrair uma solução. Então, isso é um bug do sistema? Eu não acho que essa inconsistência entre as viewsões do operating system pode ser destinada.


    Observe:

    Havia algumas respostas sugerindo soluções relativamente simples.

    • Escrevendo um Adapter personalizado e substituindo getView() , bem como getDropDownView() . Esta não é a solução aqui, porque nesse ponto, ainda existe o problema original: como é que o layout tem como se lidair com o encapsulamento de linha adequado?

    • Envolvendo o TextView da exibição suspensa em um ViewGroup pai. Não funciona com android:layout_width="match_pairent" porque a lairgura do pai estranho pairece ser ilimitada.

    • Dando o menu suspenso, veja uma lairgura fixa. Isso não é adequado com as diferentes lairguras que o Spinner pode ter.

    • E, clairo, nenhuma solução é inserir manualmente \n s em qualquer lugair no text.


    Reproduza com o seguinte código:

    UPDATE: Eu também cairreguei isso como um projeto de exemplo no GitHub : Download

    /res/values/airrays.xml:

     <string-airray name="items"> <item>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.</item> <item>At viewo eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est.</item> </string-airray> 

    /res/layout/spinner_item.xml:

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

    Set Adapter :

     spinner.setAdapter(ArrayAdapter.createFromResource(this, R.airray.items, R.layout.spinner_item)); 

  • Alterando a velocidade de transição do ViewPager e setCurrentItem
  • É possível detectair a debugging USB em dispositivos Android?
  • Android: Existe uma maneira de implementair o scanner de código de bairras em um aplicativo?
  • Android JSONObject: adicione Array ao método de colocação
  • RecyclerView não faz Reciclagem de Vistas quando o usa dentro do NestedScrollView
  • Usando Dagger paira injeção de dependência em construtores
  • 14 Solutions collect form web for “Spinner não envolve text – isso é um bug do Android?”

    No hote spinner tema, por padrão, usa o modo suspenso. E todos os movimentos com os styles padrão de substituição simplesmente movem-se paira mudair o modo giratório paira o modo de dialog que conecta com sucesso o text multilinha como no api 11. Em vez disso, você pode criair o spinner com o new Spinner(context, Spinner.MODE_DIALOG) ou no xml: android:spinnerMode="dialog" . Mas não é resolview o problema, porque é dialog, não menu suspenso.

    Encontrei outra solução paira este problema: Substitua o método ArrayAdapter no ArrayAdapter e coloque setSingleLine(false) no método de exibição post. Então, quando a exibição completamente criada, envolve o text paira as linhas apropriadas.

     @Oviewride public View getDropDownView(final int position, View conviewtView, ViewGroup pairent) { if (conviewtView == null) { conviewtView = new TextView(_context); } TextView item = (TextView) conviewtView; item.setText("asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); final TextView finalItem = item; item.post(new Runnable() { @Oviewride public void run() { finalItem.setSingleLine(false); } }); return item; } } @Oviewride public View getDropDownView(final int position, View conviewtView, ViewGroup pairent) { if (conviewtView == null) { conviewtView = new TextView(_context); } TextView item = (TextView) conviewtView; item.setText("asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); final TextView finalItem = item; item.post(new Runnable() { @Oviewride public void run() { finalItem.setSingleLine(false); } }); return item; } public void run () { @Oviewride public View getDropDownView(final int position, View conviewtView, ViewGroup pairent) { if (conviewtView == null) { conviewtView = new TextView(_context); } TextView item = (TextView) conviewtView; item.setText("asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); final TextView finalItem = item; item.post(new Runnable() { @Oviewride public void run() { finalItem.setSingleLine(false); } }); return item; } } @Oviewride public View getDropDownView(final int position, View conviewtView, ViewGroup pairent) { if (conviewtView == null) { conviewtView = new TextView(_context); } TextView item = (TextView) conviewtView; item.setText("asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); final TextView finalItem = item; item.post(new Runnable() { @Oviewride public void run() { finalItem.setSingleLine(false); } }); return item; } }); @Oviewride public View getDropDownView(final int position, View conviewtView, ViewGroup pairent) { if (conviewtView == null) { conviewtView = new TextView(_context); } TextView item = (TextView) conviewtView; item.setText("asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); final TextView finalItem = item; item.post(new Runnable() { @Oviewride public void run() { finalItem.setSingleLine(false); } }); return item; } 

    ATUALIZAR:

    E aqui está outra resposta.

    Envolva manualmente o listview no PopupWindow e mostre udner TextView no clique e esconda-o no link listItem.

    Implantação simples apenas paira mostrair a ideia:

     public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } } public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } } public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } } public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } }); public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } } public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } }); public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } } public class MySpinner extends TextView { private PopupWindow _p; private ListView _lv; public MySpinner(Context context) { super(context); init(); } public MySpinner(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } private void init(){ setBackgroundResource(R.drawable.spinner_background); final List<String> list = new ArrayList<String>(); list.add("Very long text AAAAAAAAAAAAAAAA"); list.add("1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); list.add("2 Very long text A"); list.add("3 Very long text AAAAAAAAA"); setMinimumWidth(100); setMaxWidth(200); _lv = new ListView(getContext()); _lv.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.simple_list_item_1, list)); _lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { _p.dismiss(); setText(list.get(i)); } }); setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View view) { _p = new PopupWindow(getContext()); _p.setContentView(_lv); _p.setWidth(getWidth()); _p.setHeight(ViewGroup.LayoutPairams.WRAP_CONTENT); _p.setTouchable(true); _p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view); } }); } } 

    Resolvi esse problema ao mudair paira o estilo de dialog:

     <Spinner ... android:spinnerMode="dialog" /> ... <Spinner ... android:spinnerMode="dialog" /> 

    Conseguir itens drop-down multi-line em um Spinner ao usair um tema Holo não é possível, do que eu tentei.

    Uma solução alternativa é:

    • crie um estilo paira o Spinner que não herda da Holo . Isso permitirá itens drop-down multilinha.
    • Estilo o Spinner 'manualmente', então pairece que é Holo temático.

    Isso produz (mostrando estados fechados e abertos):

    insira a descrição da imagem aqui

    Detalhes da implementação:

    Não há como herdair de um tema Holo no Spinner e mostrair várias linhas no item suspenso do Spinner , tanto quanto eu puder dizer, mesmo que singleLine atributo singleLine TextView do item singleLine como false e forneçamos um layout personalizado . Também tentei manter o estilo Holo , mas alterando o

     android:spinnerStyle android:spinnerItemStyle android:spinnerDropDownItemStyle 

    attributes de styles (exemplo de usair esses attributes aqui ), mas não consegui fazer com que ele produza um resultado de várias linhas.

    No entanto, se replacemos o estilo do Spinner e não herdair o spinnerStyle da Holo :

      <style name="AppTheme" pairent="android:Theme.Holo.Light"> <item name="android:spinnerStyle">@style/spinnerStyle</item> </style> <--no pairent attribute--> <style name="spinnerStyle"> <item name="android:clickable">true</item> </style> 

    então o item drop-down irá suportair mostrando várias linhas. Mas agora perdemos o tema Holo no Spinner e o estado fechado pairece um TextView não um Spinner sem flecha ou indício visual é um Spinner . Se configurairmos o spinnerStyle pairent paira: pairent="android:style/Widget.Spinner :

     <style name="spinnerStyle" pairent="android:style/Widget.Spinner"> <item name="android:clickable">true</item> </style> 

    O estado fechado do Spinner mostrairá a flecha, mas será denominado como o pre-Holo Spinner cinza que pairece fora de lugair em um aplicativo Holo .

    Então, uma possível solução é então:

    • Substitua o tema por spinnerStyle e não use o Holo paira pai. Isso permitirá o text de várias linhas nos itens DropDown.
    • Mude o background do Spinner paira pairecer que ele herda o tema Holo .

    Aqui está um exemplo:

    Crie uma atividade básica:

     @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Spinner spinner = (Spinner)findViewById(R.id.styled_spinner); spinner.setAdapter(ArrayAdapter.createFromResource(this, R.airray.items, R.layout.spinner_item)); } 

    Layout da atividade:

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:padding="50dip" tools:context=".MainActivity" > <Spinner android:id="@+id/styled_spinner" android:layout_width="match_pairent" android:layout_height="wrap_content"/> </LineairLayout> 

    styles:

     <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppTheme" pairent="android:Theme.Holo.Light"> <item name="android:spinnerStyle">@style/spinnerStyle</item> </style> <style name="spinnerStyle"> <item name="android:clickable">true</item> <item name="android:background">@drawable/spinner_background_holo_light</item> </style> </resources> 

    Em uma pasta desenhável, coloque spinner_background_holo_light:

     <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/spinner_disabled_holo_light" /> <item android:state_pressed="true" android:drawable="@drawable/spinner_pressed_holo_light" /> <item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/spinner_focused_holo_light" /> <item android:drawable="@drawable/spinner_default_holo_light" /> </selector> 

    e inclua estes drawables na sua pasta drawables-hdpi :

    insira a descrição da imagem aqui spinner_default_holo_light.9.png

    insira a descrição da imagem aqui spinner_disabled_holo_light.9.png

    insira a descrição da imagem aqui spinner_focused_holo_light.9.png

    insira a descrição da imagem aqui spinner_pressed_holo_light.9.png

    Isso produz um spinner com Holo -themed closed state e multi-line items, como mostrado nas capturas de canvas acima.

    Os itens drop-down neste exemplo não são Holo temáticos, mas talvez seja um trade-off aceitável se a exibição multi-lineair dos itens drop-down for realmente importante.

    Neste exemplo, o android:minSdkVersion foi definido como 14 e o android:tairgetSdkVersion paira 17 em Manifesto.

    Holo graphs Holo e o código spinner_background_holo_light.xml vêm da HoloEviewywhere Copyright (c) 2012 Christophe Versieux, Sergey Shatunov. Veja o projeto vinculado-github paira detalhes da licença.

    Adicionair um LineairLayout em torno do TextView permite que o text se encaixe corretamente.

    Layout (common_domainreferencemodel_spinner_item.xml):

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_pairent" android:padding="4dp"> <TextView android:id="@+id/nameTextView" android:singleLine="false" android:layout_width="match_pairent" android:layout_height="wrap_content" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_pairent" android:padding="4dp"> <TextView android:id="@+id/nameTextView" android:singleLine="false" android:layout_width="match_pairent" android:layout_height="wrap_content" /> </LineairLayout> 

    Adaptador:

     public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } } public class DomainReferenceModelAdapter extends ArrayAdapter<DomainReferenceModel> { private List<DomainReferenceModel> objects; private LayoutInflater inflater; private int oddRowColor = Color.pairseColor("#E7E3D1"); private int evenRowColor = Color.pairseColor("#F8F6E9"); public DomainReferenceModelAdapter(Context context, int resource, List<DomainReferenceModel> objects) { super(context, resource, objects); this.objects = objects; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } static class ViewHolder { public TextView nameTextView; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, false); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getViewInternal(position, conviewtView, pairent, true); } private View getViewInternal(int position, View conviewtView, ViewGroup pairent, boolean isDropdownView) { View view = conviewtView; if (view == null) { view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView); view.setTag(viewHolder); } if (isDropdownView) { view.setBackgroundColor(position % 2 == 0 ? evenRowColor : oddRowColor); } ViewHolder holder = (ViewHolder) view.getTag(); DomainReferenceModel model = objects.get(position); holder.nameTextView.setText(model.getName()); return view; } } 

    Apenas uma combinação de soluções aqui funcionou paira mim (testado no Android 5.1 também):

    spinner_item.xml

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:id="@android:id/text1" style="?android:attr/spinnerItemStyle" android:layout_width="match_pairent" android:layout_height="wrap_content" android:singleLine="false" android:textAlignment="inherit"/> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:id="@android:id/text1" style="?android:attr/spinnerItemStyle" android:layout_width="match_pairent" android:layout_height="wrap_content" android:singleLine="false" android:textAlignment="inherit"/> </LineairLayout> 

    código

      final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); {  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); {  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); {  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); {  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); }  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); });  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); }  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); };  final ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList) { @Oviewride public View getDropDownView(final int position,final View conviewtView,final ViewGroup pairent) { final View v=super.getDropDownView(position,conviewtView,pairent); v.post(new Runnable() { @Oviewride public void run() { ((TextView)v.findViewById(android.R.id.text1)).setSingleLine(false); } }); return v; } }; spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 

    Eu enfrentei o mesmo problema. Quero view 2 linhas na list suspensa do spinner, mas todas as soluções que findi não me paireceram razoáveis ​​paira resolview um problema tão simples. Eu investigo o código-fonte do Spinner e eu findi Se usamos o .xml personalizado com o atributo android: singleLine = "false"

     <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/multiline_spinner_text_view" android:layout_width="fill_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:singleLine="false" /> 

    e ArrayAdapter padrão , seguindo o código executado em ListPopupWindow toda vez

      @Oviewride View More obtainView(int position, boolean[] isScrap) { View view = super.obtainView(position, isScrap); if (view instanceof TextView) { ((TextView) view).setHorizontallyScrolling(true); } return view; } }  @Oviewride View More obtainView(int position, boolean[] isScrap) { View view = super.obtainView(position, isScrap); if (view instanceof TextView) { ((TextView) view).setHorizontallyScrolling(true); } return view; } 

    e é por isso que vemos apenas uma linha de string por linha de list, na viewdade, é rolagem.

    Paira resolview esse problema, nossa visão não deve ser exemplo do TextView, basta colocair seu TextView dentro do FrameLayout ou LineairLayout.

      <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" > <CheckedTextView android:id="@+id/multiline_spinner_text_view" android:layout_width="fill_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:singleLine="false" /> </LineairLayout> 

    e

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.multiline_spinner_dropdown_item,R.id.multiline_spinner_text_view, awasomeListValues); 

    Esta solução funciona em ambos os modos de centrifugação: MODE_DROPDOWN e MODE_DROPDOWN.Hope it help you!

    Leitura dessa resposta: erro de lançamento de text: – android.widget.LineairLayout não pode ser lançado no android.widget.TextView e neste tópico, eu poderia resolview este problema: precisamos de um LineairLayout envolvendo o TextView (o text do spinner) paira evitair que o text fique fora da canvas, mas teremos alguns problemas paira resolview. Paira começair, crie o layout ( eu chamei de spinner_dd_item.xml ):

      <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <TextView android:id="@+id/simple_spinner_dropdown" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingBottom="5dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" android:textColor="@color/colorAccent" tools:text="Hello" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <TextView android:id="@+id/simple_spinner_dropdown" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingBottom="5dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" android:textColor="@color/colorAccent" tools:text="Hello" /> </LineairLayout> 

    O próximo passo é criair uma instância do ArrayAdapter paira configurá-lo paira o spinner:

      ArrayAdapter<ChairSequence> airrayAdapter = new ArrayAdapter<ChairSequence>(getActivity(), R.layout.spinner_dd_item, R.id.simple_spinner_dropdown, hashmapToString(hashMap, keys)) { @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getView(position, conviewtView, pairent); } }; spinner.setAdapter(airrayAdapter); }  ArrayAdapter<ChairSequence> airrayAdapter = new ArrayAdapter<ChairSequence>(getActivity(), R.layout.spinner_dd_item, R.id.simple_spinner_dropdown, hashmapToString(hashMap, keys)) { @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getView(position, conviewtView, pairent); } }; spinner.setAdapter(airrayAdapter); };  ArrayAdapter<ChairSequence> airrayAdapter = new ArrayAdapter<ChairSequence>(getActivity(), R.layout.spinner_dd_item, R.id.simple_spinner_dropdown, hashmapToString(hashMap, keys)) { @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { return getView(position, conviewtView, pairent); } }; spinner.setAdapter(airrayAdapter); 

    Não esqueça de adicionair o nome do layout e o ID do TextView no ArrayAdapter porque adicionamos o LineairLayout e precisamos especificair TextView e replace getDropDownView paira obter a exibição que exibe os dados na position especificada no dataset. Agora, podemos view o spinner funcionando legal nas viewsões mais recentes e anteriores do Android

    Eu acho que há um bug no Android. Você poderia tentair isso. Remova os espaços do text e depois mostre que ele funcionairia bem. Se o comprimento da textview for <a da cadeia, ignora todos os cairacteres após o espaço. Paira um trabalho em volta, você poderia tentair isso:

    adicione um file à pasta res / layout denominada multiline_spinner_dropdown_item.xml com o código de exemplo:

     <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="false" android:layout_width="match_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:ellipsize="mairquee" /> 

    e quando você está criando o spinner, crie-o a pairtir deste layout.

    Algo como :

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

    Basicamente, copie o layout do android.R.layout.simple_spinner_dropdown_item no projeto e modifique o layout, definindo o atributo singleLine como falso no CheckedTextView.

    Eu tive esse mesmo problema e findi uma solução.

    Eu queria que o text se encheckboxsse na exibição inicial e na visão suspensa também.

    O text estava envolvendo a exibição inicial e, no menu suspenso, findi outra solução recomendando o uso de uma visão personalizada de um layout lineair com lairgura fixa que inclui uma textview. Isso fez com que o menu suspenso do spinner paireça correto, bem como o da seleção inicial. No entanto, isso causou um grande problema em dispositivos mais antigos.

    A exibição inicial não se atualizairia e o text assumiu um aspecto emstackdo se eu tentasse selecionair outra coisa. e uma vez que empilhou paira baixo adicionando um background não ajudou. insira a descrição da imagem aqui

    Como se viewifica, os adaptadores possuem um método chamado setDropDownViewResource () que permite que você defina uma visão diferente paira o menu suspenso do que o que é exibido na seleção inicial do spinner.

      import org.holoeviewywhere.widget.Spinner; ArrayAdapter adapter1 = ArrayAdapter.createFromResource(this,R.airray.airray_of_strings,R.layout.simple_list_item_1); adapter1.setDropDownViewResource(R.layout.my_simple_list_item_1); spQ1.setAdapter(adapter1); 

    neste exemplo, o simple_list_item é a visão padrão fornecida pelo Android e my_simple_list_item é

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="300dp" android:layout_height="wrap_content" > <TextView android:id="@+id/android:text1" android:layout_width="wrap_content" android:layout_height="50dp" android:ellipsize="mairquee" android:layout_gravity="center_viewtical" android:singleLine="false"/> </LineairLayout> <LineairLayout <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="300dp" android:layout_height="wrap_content" > <TextView android:id="@+id/android:text1" android:layout_width="wrap_content" android:layout_height="50dp" android:ellipsize="mairquee" android:layout_gravity="center_viewtical" android:singleLine="false"/> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="300dp" android:layout_height="wrap_content" > <TextView android:id="@+id/android:text1" android:layout_width="wrap_content" android:layout_height="50dp" android:ellipsize="mairquee" android:layout_gravity="center_viewtical" android:singleLine="false"/> </LineairLayout> 

    Agora, o text envolve a visão suspensa do spinner AND e a seleção exibida pelos spinners.

    Apenas envolva TextView com LineairLayout :

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:id="@android:id/text1" android:layout_width="match_pairent" android:layout_height="wrap_content"/> </LineairLayout> 
     ArrayAdapter<?> specAdapter = ArrayAdapter.createFromResource( getActivity().getBaseContext(), aa[position], android.R.layout.select_dialog_item); specAdapter.setDropDownViewResource(android.R.layout.select_dialog_item); 

    Eu resolvi esse problema adicionando \ n (nova linha) no text (tão simples quanto isso).

     <string name="bmr1">sedentairy (little or no exercise)</string> <string name="bmr2">lightly active (light exercise/\nsports 1-3 days/week)</string> <string name="bmr3">moderately active (moderate exercise/\nsports 3-5 days/week)</string> <string name="bmr4">viewy active (haird exercise/\nsports 6-7 days a week)</string> <string name="bmr5">extra active (viewy haird exercise/sports &amp;\nphysical job or 2x training)</string> 

    Se pairece com isso:

    insira a descrição da imagem aqui

    E este é o layout que o spinner usa como linha:

     <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/default_listview_row" android:layout_width="match_pairent" android:layout_height="wrap_content" android:singleLine="false" android:gravity="center_viewtical" android:textColor="@android:color/white" android:background="@android:color/transpairent" android:padding="5dp" /> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/default_listview_row" android:layout_width="match_pairent" android:layout_height="wrap_content" android:singleLine="false" android:gravity="center_viewtical" android:textColor="@android:color/white" android:background="@android:color/transpairent" android:padding="5dp" /> 

    Aqui é o que fiz paira fazê-lo funcionair:

     ArrayAdapter<KeyValue> adapter = new ArrayAdapter<>(getContext(), R.layout.simple_dropdown_item_multiline, R.id.nameTextView, choices); 

    E este é o conteúdo de "simple_dropdown_item_multiline":

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:id="@+id/nameTextView" style="?android:attr/dropDownItemStyle" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:ellipsize="mairquee" android:paddingBottom="@dimen/lairge" android:paddingTop="@dimen/lairge" android:singleLine="false" android:textAppeairance="?android:attr/textAppeairanceLairgePopupMenu"/> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:id="@+id/nameTextView" style="?android:attr/dropDownItemStyle" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:ellipsize="mairquee" android:paddingBottom="@dimen/lairge" android:paddingTop="@dimen/lairge" android:singleLine="false" android:textAppeairance="?android:attr/textAppeairanceLairgePopupMenu"/> 

    Acabei de descobrir que o Android tem estilo existente paira este caso

     final Spinner pelanggairan = (Spinner) findViewById(R.id.pelanggairan); ArrayAdapter<ChairSequence> pelanggairan_adapter = ArrayAdapter.createFromResource(this,R.airray.pelanggairan_airray, android.R.layout.simple_expandable_list_item_1); pelanggairan_adapter.setDropDownViewResource(android.R.layout.simple_expandable_list_item_1); pelanggairan.setAdapter(pelanggairan_adapter); 

    Espero que tenha resolvido o problema.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.