material design - How can I use Light SearchView on Dark App Bar on android? -
this main activity xml:
<android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.appbarlayout> <include layout="@layout/content_main" /> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_menu_search" />
this styles.xml
<style name="apptheme" parent="theme.appcompat.light"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/coloraccent</item> </style> <style name="apptheme.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> </style> <style name="apptheme.appbaroverlay" parent="themeoverlay.appcompat.dark.actionbar"> </style> <style name="apptheme.popupoverlay" parent="themeoverlay.appcompat.light" />
the problem want use white text on appbar, @ same time want search suggestions have dark text on white background (like holo). suggestions shown in dark theme. if use themeoverlay.appcompat.actionbar, suggestions turn white text on appbar turned black, , want remain white.
please me! attaching screenshots demonstration purposes:
here how succeeded achieve that:
you need override styles autocompletetextviewstyle
, textappearancesearchresulttitle
in theme:
<style name="apptheme" parent="theme.appcompat.light.noactionbar"> <item name="autocompletetextviewstyle">@style/myautocompletetextviewstyle</item> <item name="textappearancesearchresulttitle">@style/mysearchresult</item> ... </style> <style name="myautocompletetextviewstyle" parent="widget.appcompat.light.autocompletetextview"> <item name="android:popupbackground">@color/white</item> </style> <style name="mysearchresult" parent="textappearance.appcompat.searchresult.title"> <item name="android:textcolor">@color/black</item> </style>
Comments
Post a Comment