Java Code Examples for android.widget.EdgeEffect#setColor()
The following examples show how to use
android.widget.EdgeEffect#setColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidUtilities.java From KrGallery with GNU General Public License v2.0 | 6 votes |
public static void setListViewEdgeEffectColor(AbsListView listView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = AbsListView.class.getDeclaredField("mEdgeGlowTop"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(listView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = AbsListView.class.getDeclaredField("mEdgeGlowBottom"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(listView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { e.printStackTrace(); } } }
Example 2
Source File: Easel.java From andela-crypto-app with Apache License 2.0 | 6 votes |
/** * Tint the edge effect when you reach the end of a scroll view. API 21+ only * * @param scrollableView the scrollable view, such as a {@link android.widget.ScrollView} * @param color the color * @return true if it worked, false if it did not */ @TargetApi(21) public static boolean tintEdgeEffect(@NonNull View scrollableView, @ColorInt int color) { //http://stackoverflow.com/questions/27104521/android-lollipop-scrollview-edge-effect-color boolean outcome = false; final String[] edgeGlows = {"mEdgeGlowTop", "mEdgeGlowBottom", "mEdgeGlowLeft", "mEdgeGlowRight"}; for (String edgeGlow : edgeGlows) { Class<?> clazz = scrollableView.getClass(); while (clazz != null) { try { final Field edgeGlowField = clazz.getDeclaredField(edgeGlow); edgeGlowField.setAccessible(true); final EdgeEffect edgeEffect = (EdgeEffect) edgeGlowField.get(scrollableView); edgeEffect.setColor(color); outcome = true; break; } catch (Exception e) { clazz = clazz.getSuperclass(); } } } return outcome; }
Example 3
Source File: ViewCompat.java From support with Apache License 2.0 | 6 votes |
public static void setEdgeEffectColor(final EdgeEffect edgeEffect, @ColorRes final int color) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { edgeEffect.setColor(color); return; } final Field edgeField = EdgeEffect.class.getDeclaredField("mEdge"); final Field glowField = EdgeEffect.class.getDeclaredField("mGlow"); edgeField.setAccessible(true); glowField.setAccessible(true); final Drawable edge = (Drawable) edgeField.get(edgeEffect); final Drawable glow = (Drawable) glowField.get(edgeEffect); edge.setColorFilter(color, PorterDuff.Mode.SRC_IN); glow.setColorFilter(color, PorterDuff.Mode.SRC_IN); edge.setCallback(null); // free up any references glow.setCallback(null); // free up any references } catch (final Exception ignored) { ignored.printStackTrace(); } }
Example 4
Source File: AndroidUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ViewPager.class.getDeclaredField("mLeftEdge"); field.setAccessible(true); EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager); if (mLeftEdge != null) { mLeftEdge.setColor(color); } field = ViewPager.class.getDeclaredField("mRightEdge"); field.setAccessible(true); EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager); if (mRightEdge != null) { mRightEdge.setColor(color); } } catch (Exception ignore) { } } }
Example 5
Source File: AndroidUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }
Example 6
Source File: AndroidUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = ScrollView.class.getDeclaredField("mEdgeGlowBottom"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }
Example 7
Source File: AndroidUtilities.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ViewPager.class.getDeclaredField("mLeftEdge"); field.setAccessible(true); EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager); if (mLeftEdge != null) { mLeftEdge.setColor(color); } field = ViewPager.class.getDeclaredField("mRightEdge"); field.setAccessible(true); EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager); if (mRightEdge != null) { mRightEdge.setColor(color); } } catch (Exception ignore) { } } }
Example 8
Source File: AndroidUtilities.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }
Example 9
Source File: AndroidUtilities.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = ScrollView.class.getDeclaredField("mEdgeGlowBottom"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }
Example 10
Source File: AndroidUtilities.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = ScrollView.class.getDeclaredField("mEdgeGlowBottom"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }
Example 11
Source File: AndroidUtilities.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) { if (Build.VERSION.SDK_INT >= 21) { try { Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop"); field.setAccessible(true); EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView); if (mEdgeGlowTop != null) { mEdgeGlowTop.setColor(color); } field = ScrollView.class.getDeclaredField("mEdgeGlowBottom"); field.setAccessible(true); EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView); if (mEdgeGlowBottom != null) { mEdgeGlowBottom.setColor(color); } } catch (Exception e) { FileLog.e(e); } } }