Android 为什么不';AppCompat v21 SearchView样式在我的应用程序中是否有效?

Android 为什么不';AppCompat v21 SearchView样式在我的应用程序中是否有效?,android,material-design,android-theme,searchview,android-appcompat,Android,Material Design,Android Theme,Searchview,Android Appcompat,我正在尝试遵循中的“SearchView小部件”部分。我在我的res/values-v21/styles.xml中添加了searchIcon、queryBackground和submitBackground值,但这些样式似乎不适用: 我正在发布SSCCE和的代码,以防有人想尝试 SSCCE res/values-v21/styles.xml <?xml version="1.0" encoding="utf-8"?> <resources> <style

我正在尝试遵循中的“SearchView小部件”部分。我在我的
res/values-v21/styles.xml
中添加了
searchIcon
queryBackground
submitBackground
值,但这些样式似乎不适用:

我正在发布SSCCE和的代码,以防有人想尝试

SSCCE

res/values-v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- <item name="android:colorPrimary">@color/primaryColor</item>
        <item name="android:colorPrimaryDark">@color/primaryColorDark</item>
        <item name="android:colorAccent">@color/accentColor</item>-->

        <item name="searchViewStyle">@style/CustomSearchViewStyle</item>
    </style>

    <style name="CustomSearchViewStyle" parent="Widget.AppCompat.SearchView">
        <!-- Search button icon -->
        <item name="searchIcon">@drawable/ic_account_circle_black_24dp</item>
        <!-- Background for the search query section (e.g. EditText) -->
        <item name="queryBackground">@color/searchViewQueryBackground</item> <!-- Lime 100 -->
        <!-- Background for the actions section (e.g. voice, submit) -->
        <item name="submitBackground">@color/searchViewSubmitBackground</item> <!-- Brown 100 -->
    </style>
</resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primaryColorDark</item>
        <item name="colorAccent">@color/accentColor</item>
    </style>


    <style name="AppTheme" parent="AppBaseTheme">
    </style>


    <style name="CustomToolbarTheme" parent="AppBaseTheme">
        <item name="android:textColorPrimary">#FFFFFF</item>
        <item name="android:textColorSecondary">#FFA400</item>
    </style>

    <style name="CustomToolbarPopupTheme" parent="AppBaseTheme">
        <item name="android:background">#1976D2</item>
    </style>

</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primaryColor">#2196F3</color> <!-- Blue 500 -->
    <color name="primaryColorDark">#1976D2</color> <!-- Blue 700 -->
    <color name="accentColor">#C51162</color> <!-- Maroon Dark  -->

    <color name="searchViewQueryBackground">#F0F4C3</color><!-- Lime 100 -->
    <color name="searchViewSubmitBackground">#D7CCC8</color><!-- Brown 100 -->
</resources>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="practice_projects.material_design_google_now_like_searchbox_four.MainActivity" >

    <include android:id="@+id/mainActivity_toolBar"
        layout="@layout/app_bar" />

    <TextView
        android:layout_below="@id/mainActivity_toolBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    app:theme="@style/CustomToolbarTheme"
    app:popupTheme="@style/CustomToolbarPopupTheme" >

    <include android:id="@+id/appBar_searchBox"
        layout="@layout/search_box" />

</android.support.v7.widget.Toolbar>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.SearchView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="@string/searchHint"
    app:iconifiedByDefault="false" >


</android.support.v7.widget.SearchView>

没有人知道原因
public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        toolbar = (Toolbar) findViewById(R.id.mainActivity_toolBar);

        setSupportActionBar(toolbar);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(getResources().getColor(R.color.primaryColorDark)); 
        }

        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources() 
                .getColor(R.color.primaryColor)));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        return super.onOptionsItemSelected(item);
    }
}