zoukankan      html  css  js  c++  java
  • android spinner默认样式不支持换行和修改字体样式 的解决方法

    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: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="?android:attr/listPreferredItemHeight"
        android:ellipsize="marquee" />
    =========================================
    //默认的不支持修改字体样式
    simple_spinner_item.xml
    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
        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" />
    大自然,飘然的风,QQ群: python技术交流群:453879716,人工智能深度学习群:251088643
    golang技术交流群:316397059,vuejs技术交流群:458915921 渗透技术:534096581,囤币一族:621258209,有兴趣的可以加入
    微信公众号:大自然预测(ssqyuce)原双色球预测, 心禅道(xinchandao)
  • 相关阅读:
    ASP.NET编程的十大技巧
    C#学习心得(转)
    POJ 1177 Picture (线段树)
    POJ 3067 Japan (树状数组)
    POJ 2828 Buy Tickets (线段树)
    POJ 1195 Mobile phones (二维树状数组)
    HDU 4235 Flowers (线段树)
    POJ 2886 Who Gets the Most Candies? (线段树)
    POJ 2418 Cows (树状数组)
    HDU 4339 Query (线段树)
  • 原文地址:https://www.cnblogs.com/zdz8207/p/2682316.html
Copyright © 2011-2022 走看看