简体   繁体   English

如何为Android SearchView创建自定义样式?

[英]How to create custom style for Android SearchView?

I have already implemented Search Interface for my app following the steps outlined in the guide below: 我已经按照以下指南中概述的步骤为我的应用实现了搜索界面:

https://developer.android.com/guide/topics/search/search-dialog https://developer.android.com/guide/topics/search/search-dialog

I want to create custom styling for the SearchView as used in Google Chrome app and Google Photos app 我想为Google Chrome应用程序和Google相册应用程序中使用的SearchView创建自定义样式

在此处输入图片说明

在此处输入图片说明

How can we style Android SearchView embedded in Toolbar using Android Support Library? 我们如何使用Android支持库为嵌入在工具栏中的Android SearchView设置样式?

I've already seen the following answer but that's limited to icons and text styling. 我已经看到了以下答案,但仅限于图标和文本样式。 I want to create custom borders and backgrounds. 我想创建自定义边框和背景。

https://stackoverflow.com/a/28018439/4419474 https://stackoverflow.com/a/28018439/4419474

You can create a drawable XML with shape rectangle and add the tags of corner radius, solid colour to define your background shape. 您可以创建一个具有矩形形状的可绘制XML,并添加圆角半径,纯色标签来定义背景形状。

Then add this drawable XML as background to the cardView. 然后将此可绘制XML作为背景添加到cardView。 Inside this cardview add your SearchView widget. 在该cardview内添加您的SearchView小部件。

Please let me know if you need any more help. 如果您需要更多帮助,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM