Reprint: http://www.cnblogs.com/wubingshenyin/p/4413672.html (original link)
The previous time saw Actionbar-pulltorefreshlibs used to refresh very good-looking, with more than 4.4 support of the immersive effect is better, so I want to cooperate with the immersion +actionbar-pulltorefreshlibs to make an effect, In their own big God F2 mobile phone see no problem, but on the Samsung Note3 on the Actionbar refresh and actionbar dislocation situation, very depressed. By debugging Actionbar-pulltorefreshlibs found that the status bar in the setting of the immersion in the height of the Samsung machine is erased (rect.top=0), The Actionbar-pulltorefreshlibs internal method (Pulltorefreshattacher Class) was manually modified to achieve immersive +actionbar-pulltorefreshlibs effects on some machines. The principle of modification is to determine whether Rect.top is 0, if it is 0 to manually get the height of the status bar to the rect set top, modify the code as follows:
protected voidaddheaderviewtoactivity (View headerview) {//Get The Display Rect of the decor ViewMactivity.getwindow (). Getdecorview (). Getwindowvisibledisplayframe (Mrect); if (mrect.top = = 0) Mrect.top = getstatusbarheight (mactivity); //honour the requested layout params intwidth =WindowManager.LayoutParams.MATCH_PARENT; intHeight =WindowManager.LayoutParams.WRAP_CONTENT; Viewgroup.layoutparams REQUESTEDLP=Headerview.getlayoutparams (); if(REQUESTEDLP! =NULL) {width=Requestedlp.width; Height=Requestedlp.height; } //Create Layoutparams for adding the View as a panelWindowmanager.layoutparams WLP =Newwindowmanager.layoutparams (width, height, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, pixelformat.translucent); Wlp.x= 0; WLP.Y=Mrect.top; Wlp.gravity=Gravity.top; //workaround for Issue #182Headerview.settag (WLP); Mactivity.getwindowmanager (). AddView (Headerview, WLP); } protected voidupdateheaderviewposition (View headerview) {//Refresh The Display Rect of the decor ViewMactivity.getwindow (). Getdecorview (). Getwindowvisibledisplayframe (Mrect); if (mrect.top = = 0) Mrect.top = getstatusbarheight (mactivity); Windowmanager.layoutparams WLP=NULL; if(Headerview.getlayoutparams ()instanceofwindowmanager.layoutparams) {WLP=(Windowmanager.layoutparams) headerview.getlayoutparams (); } Else if(Headerview.gettag ()instanceofwindowmanager.layoutparams) {WLP=(Windowmanager.layoutparams) Headerview.gettag (); } if(WLP! =NULL&& WLP.Y! =mrect.top) {wlp.y=Mrect.top; Mactivity.getwindowmanager (). Updateviewlayout (Headerview, WLP); } }
Add a method to get the height of the status bar
/*** Get status bar Height * *@return */ protected intGetstatusbarheight (Context context) {intresult = 0; intResourceId =context.getresources (). Getidentifier ("Status_bar_height", "Dimen", "Android"); if(ResourceId > 0) {result=context.getresources (). Getdimensionpixelsize (ResourceId); } returnresult; }
Run as follows:
What to note: Actionbar I did not use open source third-party components, and did not use their own actionbar, but instead hid the title in the encapsulated base class to customize the layout of the Actionbar.
Actionbar-pulltorefreshlibs+ immersive on the part of the phone layout of the confusion, currently know the Samsung System (TouchWiz)