Custom search bar with material design

I have a pointer in the layout for customizing the user dialog. I changed my .xml style to use new stuff. It works because it changes the text and checkboxes of my settings, but I cannot apply this color to my search bar. It only works if I put a search barrier in action, which means I have to do something in my custom layout, but I don't know what. I am posting styles.xml and layout with arrow:

<?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppBaseTheme" parent="android:Theme.Material"> <!-- Main theme colors --> <!-- your app branding color (for the app bar) --> <item name="android:colorPrimary">#FFFF4444</item> <!-- darker variant of colorPrimary (for status bar, contextual app bars) --> <item name="android:colorPrimaryDark">#FFCC0000</item> <!-- theme UI controls like checkboxes and text fields --> <item name="android:colorAccent">#FFFF00</item> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> </style> </resources> 

custom layout for dialog preference:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <SeekBar android:id="@+id/seek_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="6dip" android:theme="@android:style/Theme.Material" android:layout_marginTop="6dip" /> </LinearLayout> 
+4
source share
2 answers

With Lollipop, this is no longer necessary. Colors are well applied even in user preference dialogs ~ greywolf82

I want to share some custom libs

enter image description here

You can use this Material Design lib , it also includes many other widgets.

or

enter image description here

Lib DiscreteSeekBar Custom Search Bar

+5
source

You do not need to specify the android: theme attribute in the SeekBar element. Instead, you should configure the default dialogs and alert dialog box themes in your AppBaseTheme:

 <style name="AppBaseTheme" parent="android:Theme.Material"> ... <item name="android:dialogTheme">@style/AppDialogTheme</item> <item name="android:alertDialogTheme">@style/AppAlertTheme</item> </style> <style name="AppDialogTheme" parent="android:Theme.Material.Dialog"> <item name="android:colorPrimary">#FFFF4444</item> <item name="android:colorPrimaryDark">#FFCC0000</item> <item name="android:colorAccent">#FFFF00</item> </style> <!-- This should extend Theme.Material.Dialog.Alert, but that style was incorrectly hidden in L-preview. It will be fixed in a future release. You can approximate the style using the last two MinWidth attributes.--> <style name="AppAlertTheme" parent="android:Theme.Material.Dialog"> <item name="android:colorPrimary">#FFFF4444</item> <item name="android:colorPrimaryDark">#FFCC0000</item> <item name="android:colorAccent">#FFFF00</item> <item name="android:windowMinWidthMajor">65%</item> <item name="android:windowMinWidthMinor">95%</item> </style> 
+1
source

Source: https://habr.com/ru/post/978176/


All Articles