SearchView calSearchView = (SearchView) findViewById(R.id.sv_search_text);
        if (calSearchView != null) {
            try {        //--拿到字节码      
                Class<?> argClass = calSearchView.getClass();
                //--指定某个私有属性,mSearchPlate是搜索框父布局的名字        
                Field ownField = argClass.getDeclaredField("mSearchPlate");
                //--暴力反射,只有暴力反射才能拿到私有属性       
                ownField.setAccessible(true);
                View mView = (View) ownField.get(calSearchView);
                //--设置背景 
                mView.setBackgroundColor(Color.TRANSPARENT);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

 

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
  • 2021-12-25
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案