android 오버 스크롤 오프 (파랗게 번지는것 막기)
public class BaseActivity extends Activity { @Override public void onAttachedToWindow() { super.onAttachedToWindow(); //오버스크롤 오프 자동화 Utilities.patchOverScrollAllView(getWindow().getDecorView()); } }
public class Utilities { public static void patchOverScrollAllView(View view) { if (view != null) { Log.e("patchAllView", "name : " + view.getClass().getSimpleName()); if (view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) view; int len = vg.getChildCount(); for (int i = 0; i < len; i++) { View v = vg.getChildAt(i); Log.e("patchAllView", "name : " + v.getClass().getSimpleName()); if (v instanceof ScrollView) { setOverScrollModeNever(v); } else if (v instanceof ListView) { setOverScrollModeNever(v); } else if (v instanceof ExpandableListView) { setOverScrollModeNever(v); } patchOverScrollAllView(v); } } } else { Log.e("patchAllView", "name is null "); } } @SuppressWarnings("rawtypes") public static void setOverScrollModeNever(Class cls) { Class viewCls = cls.getClass(); try { Method m = viewCls.getMethod("setOverScrollMode", new Class[] { int.class }); int OVER_SCROLL_NEVER = (Integer) viewCls.getField("OVER_SCROLL_NEVER").get(cls); m.invoke(cls, OVER_SCROLL_NEVER); } catch (Exception e) { e.printStackTrace(); } } public static void setOverScrollModeNever(View v) { try { ViewCompat.setOverScrollMode(v, ViewCompat.OVER_SCROLL_NEVER); v.setVerticalFadingEdgeEnabled(false); v.setFadingEdgeLength(0); } catch (Exception e) { e.printStackTrace(); } }