Remove AutoCompleteTextView dropdown list divider

99封情书 提交于 2019-12-19 22:04:56

问题


In my application, I'm using AutoCompleteTextView. One of the requirements is to hide the divider. I have added AutoCompleteTextView to layout:

 <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" />

The style i'm using is

    <style name="searchResultsList" parent="@android:style/Widget.ListView">
    <item name="android:divider">@android:color/transparent</item>
    <item name="android:dividerHeight">0px</item>
</style>

But the divider is still there... How if can be hidden?


回答1:


Override it with your application theme. In your 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>

Credits to: http://daniel-codes.blogspot.com/2012/11/styling-autocompletetextview.html



来源:https://stackoverflow.com/questions/23359249/remove-autocompletetextview-dropdown-list-divider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!