修改SearchView搜索框的下劃線.(或着其他屬性)

去掉當SearchView得到焦點時候出現的藍色背景線.


SearchView calSearchView = (SearchView)v.findViewById(R.id.calendar_search_view);
     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();   
              }}

發佈了21 篇原創文章 · 獲贊 1 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章