Android AppCompat SearchView EditText skips bottom line on pre-lollipop

I am trying to use SearchView in my layout (not inside ToolBar or ActionBar).

<FrameLayout android:layout_width="0dp" android:layout_weight="50" android:layout_height="wrap_content" > <android.support.v7.widget.SearchView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|left" style="@style/MySearchViewStyle" /> </FrameLayout> 

I use AppCompat, but it looks different on pre-lollipop. EditText does not have a lower bound on devices with pretreatment.

Lollipop Search displays the border correctly: Lollipop SearchView with bottom border

A pre-Lellip search shows a NO border: Pre-lollipop SearchView with NO bottom border

My main topic:

  <style name="Theme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- TOOLBAR --> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <!-- Search --> <item name="searchViewStyle">@style/MySearchViewStyle</item> <item name="android:searchViewStyle">@style/MySearchViewStyle</item> <!-- COLOURS --> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary_dark</item> <item name="colorAccent">@color/accent</item> </style> <style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView"> <item name="android:editTextStyle">@style/EditText</item> <item name="editTextStyle">@style/EditText</item> </style> <style name="EditText"> <item name="android:layout_height">wrap_content</item> <item name="android:layout_width">wrap_content</item> <item name="android:inputType">text</item> <item name="android:cursorVisible">true</item> <item name="android:maxLength">1000</item> <item name="android:selectAllOnFocus">true</item> <item name="android:paddingTop">4dp</item> </style> 

Any help to ensure that my styles are consistent will be greatly appreciated.

+5
source share
1 answer

According to the source code https://github.com/android/platform_frameworks_support/blob/master/v7/appcompat/res/layout/abc_search_view.xml

search_src_text view has the background specified for @null

To get the bottom line I used

 searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text).setBackgroundResource(R.drawable.abc_textfield_search_default_mtrl_alpha); 
+5
source

All Articles