android listview show items on top of other elements
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>

add a comment |
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>

thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17
add a comment |
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>

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>

asked Nov 13 '18 at 21:03
user1439582user1439582
41110
41110
thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17
add a comment |
thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17
thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17
thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17
add a comment |
2 Answers
2
active
oldest
votes
try to set this listview on bottomsheet dialog
add a comment |
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:listSelectorxml attribute.use
setSelectormethod.
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);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289469%2fandroid-listview-show-items-on-top-of-other-elements%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
try to set this listview on bottomsheet dialog
add a comment |
try to set this listview on bottomsheet dialog
add a comment |
try to set this listview on bottomsheet dialog
try to set this listview on bottomsheet dialog
answered Nov 13 '18 at 21:19
mina shakermina shaker
12
12
add a comment |
add a comment |
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:listSelectorxml attribute.use
setSelectormethod.
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);
add a comment |
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:listSelectorxml attribute.use
setSelectormethod.
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);
add a comment |
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:listSelectorxml attribute.use
setSelectormethod.
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);
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:listSelectorxml attribute.use
setSelectormethod.
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);
answered Nov 13 '18 at 21:43
navylovernavylover
3,42021118
3,42021118
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289469%2fandroid-listview-show-items-on-top-of-other-elements%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
thanks. I have tried. but it is not working. the listview with items not displaying on other elements.
– user1439582
Nov 15 '18 at 15:17