Searchview not showing in Toolbar

前端 未结 5 1313
忘了有多久
忘了有多久 2021-02-04 14:42

I have actually a problem with my Searchview on the Support AppCompat v7 lib 24.0.0.

The SearchView is not shown up no text and input text (look screenshot)

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 15:41

    This is very odd. I'm using build tools 25.0.1 and support lib 25.1.0. For me the accepted answer was not necessary, but the way the menu item was defined needs a small change. I need it like so:

    
    
    

    Where app:showAsAction is the key. Lint underlines this as red and tells me:

    Should use android:showAsAction when using the appcompat library.

    However if I have it set to android:showAsAction then the search view simply does not appear. Go figure.

提交回复
热议问题