Customise android search view












0















I have a search view that looks like the following



search view



I want it to resemble the following



enter image description here



Following is the code



<SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:keyboardNavigationCluster="true"
android:queryHint="@string/search_teams"
android:textColor="@color/grey" />


I want to be able to left align and customize the query hint in the search view by changing the font. By default the text is center aligned, is there any way I can change that?










share|improve this question

























  • do you also want the speaker on the right?

    – Kevin Kurien
    Nov 14 '18 at 7:25











  • Yes, Also with the search view underlined

    – A.S
    Nov 14 '18 at 7:27











  • You can use a simple editText with drawableStart and drawableEnd

    – Nilesh Rathod
    Nov 14 '18 at 7:28











  • SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

    – Saran Sankaran
    Nov 14 '18 at 7:29
















0















I have a search view that looks like the following



search view



I want it to resemble the following



enter image description here



Following is the code



<SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:keyboardNavigationCluster="true"
android:queryHint="@string/search_teams"
android:textColor="@color/grey" />


I want to be able to left align and customize the query hint in the search view by changing the font. By default the text is center aligned, is there any way I can change that?










share|improve this question

























  • do you also want the speaker on the right?

    – Kevin Kurien
    Nov 14 '18 at 7:25











  • Yes, Also with the search view underlined

    – A.S
    Nov 14 '18 at 7:27











  • You can use a simple editText with drawableStart and drawableEnd

    – Nilesh Rathod
    Nov 14 '18 at 7:28











  • SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

    – Saran Sankaran
    Nov 14 '18 at 7:29














0












0








0








I have a search view that looks like the following



search view



I want it to resemble the following



enter image description here



Following is the code



<SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:keyboardNavigationCluster="true"
android:queryHint="@string/search_teams"
android:textColor="@color/grey" />


I want to be able to left align and customize the query hint in the search view by changing the font. By default the text is center aligned, is there any way I can change that?










share|improve this question
















I have a search view that looks like the following



search view



I want it to resemble the following



enter image description here



Following is the code



<SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:keyboardNavigationCluster="true"
android:queryHint="@string/search_teams"
android:textColor="@color/grey" />


I want to be able to left align and customize the query hint in the search view by changing the font. By default the text is center aligned, is there any way I can change that?







android android-layout searchview text-alignment android-search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 7:27







A.S

















asked Nov 14 '18 at 7:24









A.SA.S

261416




261416













  • do you also want the speaker on the right?

    – Kevin Kurien
    Nov 14 '18 at 7:25











  • Yes, Also with the search view underlined

    – A.S
    Nov 14 '18 at 7:27











  • You can use a simple editText with drawableStart and drawableEnd

    – Nilesh Rathod
    Nov 14 '18 at 7:28











  • SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

    – Saran Sankaran
    Nov 14 '18 at 7:29



















  • do you also want the speaker on the right?

    – Kevin Kurien
    Nov 14 '18 at 7:25











  • Yes, Also with the search view underlined

    – A.S
    Nov 14 '18 at 7:27











  • You can use a simple editText with drawableStart and drawableEnd

    – Nilesh Rathod
    Nov 14 '18 at 7:28











  • SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

    – Saran Sankaran
    Nov 14 '18 at 7:29

















do you also want the speaker on the right?

– Kevin Kurien
Nov 14 '18 at 7:25





do you also want the speaker on the right?

– Kevin Kurien
Nov 14 '18 at 7:25













Yes, Also with the search view underlined

– A.S
Nov 14 '18 at 7:27





Yes, Also with the search view underlined

– A.S
Nov 14 '18 at 7:27













You can use a simple editText with drawableStart and drawableEnd

– Nilesh Rathod
Nov 14 '18 at 7:28





You can use a simple editText with drawableStart and drawableEnd

– Nilesh Rathod
Nov 14 '18 at 7:28













SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

– Saran Sankaran
Nov 14 '18 at 7:29





SerachView is a widget/container, which internally uses many other view like textview and several other views inside to form the SerachView layout. What I would do is, read the SerachView class and find the TextView being used and then get a reference to that TextView by searchView.findViewById(serachviewTextViewId) and then apply the property to the TextView

– Saran Sankaran
Nov 14 '18 at 7:29












1 Answer
1






active

oldest

votes


















0














You need to specify Searchable Configuration in a separate xml file and set below properties



<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
</searchable>


From documentation refer here for more options




You can add voice search functionality to your search dialog or widget
by adding the android:voiceSearchMode attribute to your searchable
configuration. This adds a voice search button that launches a voice
prompt.







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%2f53295015%2fcustomise-android-search-view%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You need to specify Searchable Configuration in a separate xml file and set below properties



    <?xml version="1.0" encoding="utf-8"?>
    <searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_label"
    android:hint="@string/search_hint"
    android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
    </searchable>


    From documentation refer here for more options




    You can add voice search functionality to your search dialog or widget
    by adding the android:voiceSearchMode attribute to your searchable
    configuration. This adds a voice search button that launches a voice
    prompt.







    share|improve this answer




























      0














      You need to specify Searchable Configuration in a separate xml file and set below properties



      <?xml version="1.0" encoding="utf-8"?>
      <searchable xmlns:android="http://schemas.android.com/apk/res/android"
      android:label="@string/search_label"
      android:hint="@string/search_hint"
      android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
      </searchable>


      From documentation refer here for more options




      You can add voice search functionality to your search dialog or widget
      by adding the android:voiceSearchMode attribute to your searchable
      configuration. This adds a voice search button that launches a voice
      prompt.







      share|improve this answer


























        0












        0








        0







        You need to specify Searchable Configuration in a separate xml file and set below properties



        <?xml version="1.0" encoding="utf-8"?>
        <searchable xmlns:android="http://schemas.android.com/apk/res/android"
        android:label="@string/search_label"
        android:hint="@string/search_hint"
        android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
        </searchable>


        From documentation refer here for more options




        You can add voice search functionality to your search dialog or widget
        by adding the android:voiceSearchMode attribute to your searchable
        configuration. This adds a voice search button that launches a voice
        prompt.







        share|improve this answer













        You need to specify Searchable Configuration in a separate xml file and set below properties



        <?xml version="1.0" encoding="utf-8"?>
        <searchable xmlns:android="http://schemas.android.com/apk/res/android"
        android:label="@string/search_label"
        android:hint="@string/search_hint"
        android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
        </searchable>


        From documentation refer here for more options




        You can add voice search functionality to your search dialog or widget
        by adding the android:voiceSearchMode attribute to your searchable
        configuration. This adds a voice search button that launches a voice
        prompt.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 7:36









        Karan MerKaran Mer

        4,83032864




        4,83032864






























            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%2f53295015%2fcustomise-android-search-view%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python