android spinner默认样式不支持换行和修改字体样式 的解决方法
需求:
在spinner中显示的数据过多,需要换行,而Android自身提供的android.R.layout.simple_spinner_dropdown_item样式不支持换行,因此参考android提供的样式修改即可。
 
代码如下:
 
自定义布局文件:spinner_dropdown_item.xml
直接拷贝自android.R.layout.simple_spinner_dropdown_item,只需修改android:singleLine,将其改为false,即可支持换行。
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:andro 
    android:
    style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="false"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:ellipsize="marquee" />
=========================================
//默认的不支持修改字体样式
simple_spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:andro 
    android:gravity="left"
    android:textColor="#2A99FB"
    android:textSize="18sp"
    android:textStyle="bold"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee" />

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-12
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
相关资源
相似解决方案