SearchView去掉下划线

 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();
            }
        }

 

posted @ 2018-02-13 18:54  栗子·无限意志  阅读(1062)  评论(0编辑  收藏  举报