3 回答
TA贡献1883条经验 获得超3个赞
使用下面的方法来改变 SearchView 底线的颜色。
在这里我添加蓝色作为底线
private void customizeSearchView() {
int searchTextId = getResources().getIdentifier("android:id/search_src_text", null, null);
EditText searchBox = ((EditText) searchView.findViewById(searchTextId));
searchBox.setBackgroundColor(Color.WHITE);
searchBox.getLayoutParams().height = LinearLayout.LayoutParams.MATCH_PARENT;
int search_plateId = getResources().getIdentifier("android:id/search_plate", null, null);
View mSearchPlate = ((View) searchView.findViewById(search_plateId));
mSearchPlate.setBackgroundColor(Color.BLUE);
int searchCloseImageId = getResources().getIdentifier("android:id/search_close_btn", null, null);
ImageView searchClose = ((ImageView) searchView.findViewById(searchCloseImageId));// change color
searchClose.setBackgroundColor(Color.WHITE);
}
TA贡献1921条经验 获得超9个赞
嗨试试这个它可以帮助你
android.support.v7.widget.SearchView searchView=findViewById(R.id.search_view); View v = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate); v.setBackgroundColor(Color.parseColor("color code"));
TA贡献1779条经验 获得超6个赞
androidx.appcompat.widget.SearchView searchView = findViewById(R.id.Search_Categorie);
View v = searchView.findViewById(androidx.appcompat.R.id.search_plate);
v.setBackgroundColor(Color.parseColor("#ffffff"));
添加回答
举报