在我的应用程序中,我使用 AutoCompleteTextView。
要求之一是隐藏分隔线。
我已将 AutoCompleteTextView 添加到布局中:
<AutoCompleteTextView
android:id="@id/address_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@id/address_operation_btn"
android:background="@null"
android:completionThreshold="1"
android:dropDownAnchor="@id/anchor"
android:dropDownVerticalOffset="13dp"
android:dropDownWidth="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:layout_centerHorizontal="true"
android:hint="@string/address_bar_hint"
android:imeOptions="actionGo"
android:inputType="textUri"
android:maxLines="1"
android:saveEnabled="true"
android:singleLine="true"
android:dropDownListViewStyle="@style/searchResultsList"
android:textColor="@android:color/white"
android:textColorHint="#80FFFFFF"
android:textSize="17sp" />
我使用的风格是
<style name="searchResultsList" parent="@android:style/Widget.ListView">
<item name="android:divider">@android:color/transparent</item>
<item name="android:dividerHeight">0px</item>
</style>
但分隔符仍然存在...
如果可以隐藏怎么办?
用您的应用程序主题覆盖它。在你的themes.xml
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
</style>
<style name="DropDownListViewStyle" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:divider">@android:color/transparent</item>
<item name="android:dividerHeight">0dp</item>
</style>
致谢:http://daniel-codes.blogspot.com/2012/11/styling-autocompletetextview.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)