zoukankan      html  css  js  c++  java
  • android中巧妙更改spinner、AutoCompleteTextView分割线的颜色值(spinner AutoCompleteTextView divider color)

     这个问题本来是个不大的问题,但是遇到了就会很郁闷,Android控件的api本身就不太够强大,这个小属性找了好久没找到,今天终于解决,分享给所有遇到这个问题的朋友。

     spinner下拉列表中间有一条黑色的分割线,想要改变它的颜色值,就要重写style。

    备注:后来发现  AutoCompleteTextView 的下划线也需要同样的解决办法,所以我认为凡是使用到系统下来列表的控件,全部都需要使用注册样式来解决,就如这篇文章中我描述一样。欢迎补充

    1.首先 ,在themes里面写一个style

      <style name="applicationTheme" parent="@android:style/Theme.Light">
                    <item name="android:dropDownListViewStyle">@style/mySpinnerStyle</item>
        </style>
    
        <style name="mySpinnerStyle" parent="android:style/Widget.ListView.DropDown">
            <item name="android:divider">#00ff00</item>
            <item name="android:dividerHeight">1dp</item>
        </style>

    2.然后再它的父activity在manifest 下,写一个自定义的themes样式,引用这个就行了。

         <activity
                android:name="org.videolan.vlcn.vrActivity"
                android:configChanges="orientation|screenSize|keyboardHidden"
                android:launchMode="singleTask"
                android:screenOrientation="portrait"
                android:theme="@style/applicationTheme" >
                <intent-filter >
                    <action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY" />
                    <category android:name="android.intent.category.DEFAULT"/>
                </intent-filter>
            </activity>

    3.当前是蓝色的线,效果如下:

  • 相关阅读:
    学习笔记::有上下界的网络流
    zoj2314
    bzoj3261
    bzoj 1898
    bzoj4009
    bzoj4033
    bzoj3389
    bzoj2427
    uva 11825
    交换A与B值的四种方法
  • 原文地址:https://www.cnblogs.com/yejiurui/p/3723465.html
Copyright © 2011-2022 走看看