I have series of elements in android layout as shown in attached image. one of the element is searchview and below searchview, there are other elements. i have written a code to display list items. when i click on searchView, the list items are shown. but i want the list items to be shown on top of /over lay other elements below search view. so when i add "drawSelectorOnTop", list items still not shown on top of other elements.
<ListView
android:id="@+id/list_view"
style="@style/toolbarText"
android:layout_width="250dp"
android:layout_height="20dp"
android:layout_above="@+id/works_in"
android:layout_alignParentTop="true"
android:background="@color/white"
android:drawSelectorOnTop="true"
android:visibility="visible">
</ListView>
尝试在底部对话框上设置此listview
In addition to add android:drawSelectorOnTop="true"
, you also need set a Drawable that should be used to highlight the currently selected item.
Two ways:
use android:listSelector
xml attribute.
use setSelector
method.
And you should create a selector xml in drawable
folder like below:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@color/gray" />
</selector>
suppose the name of this selector xml file is my_selector
, then you could do like:
your_list.setSelector( R.drawable.my_selector);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.