Search code examples
androidandroid-layoutsearchview

xml version of iconifiedByDefault ignored


Why is the line android:iconifiedByDefault="false” always ignored, requiring me to always have to find a way to do it automatically? If it’s always going to be ignored, why include it as an option? Am I missing something?


Solution

  • Like most of the Views in the support libraries, the v7 appcompat SearchView uses attributes specific to it that are defined in the app's namespace, rather than the system namespace. This ensures that the attributes can be used in all Android versions that the library supports.

    You just need to use your app's namespace prefix on the iconifiedByDefault attribute. For example:

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        ... >
    
        <android.support.v7.widget.SearchView
            ...
            app:iconifiedByDefault="false" />
    
    </RelativeLayout>