android listview show items on top of other elements












1















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>


enter image description here










share|improve this question























  • 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
















1















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>


enter image description here










share|improve this question























  • 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














1












1








1








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>


enter image description here










share|improve this question














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>


enter image description here







android list android-layout android-listview items






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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












2 Answers
2






active

oldest

votes


















0














try to set this listview on bottomsheet dialog






share|improve this answer































    0














    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:




    1. use android:listSelector xml attribute.


    2. 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);





    share|improve this answer























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      0














      try to set this listview on bottomsheet dialog






      share|improve this answer




























        0














        try to set this listview on bottomsheet dialog






        share|improve this answer


























          0












          0








          0







          try to set this listview on bottomsheet dialog






          share|improve this answer













          try to set this listview on bottomsheet dialog







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 21:19









          mina shakermina shaker

          12




          12

























              0














              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:




              1. use android:listSelector xml attribute.


              2. 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);





              share|improve this answer




























                0














                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:




                1. use android:listSelector xml attribute.


                2. 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);





                share|improve this answer


























                  0












                  0








                  0







                  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:




                  1. use android:listSelector xml attribute.


                  2. 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);





                  share|improve this answer













                  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:




                  1. use android:listSelector xml attribute.


                  2. 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);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 21:43









                  navylovernavylover

                  3,42021118




                  3,42021118






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      List item for chat from Array inside array React Native

                      Thiostrepton

                      Caerphilly