当前位置: 首页>>代码示例>>Java>>正文


Java EdgeEffect.setColor方法代码示例

本文整理汇总了Java中android.widget.EdgeEffect.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeEffect.setColor方法的具体用法?Java EdgeEffect.setColor怎么用?Java EdgeEffect.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.EdgeEffect的用法示例。


在下文中一共展示了EdgeEffect.setColor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tintEdgeEffect

import android.widget.EdgeEffect; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:30,代码来源:Easel.java

示例2: setListViewEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
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) {
            FileLog.e("tmessages", e);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:22,代码来源:AndroidUtilities.java

示例3: setListViewEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:22,代码来源:AndroidUtilities.java

示例4: setEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
public static void setEdgeEffectColor(EdgeEffect edgeEffect, int color) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            edgeEffect.setColor(color);
            return;
        }
        Field edgeField = EdgeEffect.class.getDeclaredField("mEdge");
        Field glowField = EdgeEffect.class.getDeclaredField("mGlow");
        edgeField.setAccessible(true);
        glowField.setAccessible(true);
        Drawable mEdge = (Drawable) edgeField.get(edgeEffect);
        Drawable mGlow = (Drawable) glowField.get(edgeEffect);
        mEdge.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        mGlow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        mEdge.setCallback(null); // free up any references
        mGlow.setCallback(null); // free up any references
    } catch (Exception ignored) {

    }
}
 
开发者ID:EuphoriaDev,项目名称:euphoria-vk-client,代码行数:21,代码来源:AndroidUtils.java

示例5: setListViewEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:22,代码来源:AndroidUtilities.java

示例6: applyEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
void applyEdgeEffectColor(EdgeEffectCompat edgeEffectCompat) {
    if (Build.VERSION.SDK_INT >= 21 && glowColor != 0) {
        try {
            Field field = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
            field.setAccessible(true);
            EdgeEffect edgeEffect = (EdgeEffect) field.get(edgeEffectCompat);
            if (edgeEffect != null) {
                edgeEffect.setColor(glowColor);
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:15,代码来源:RecyclerView.java

示例7: setEdgeGlowColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void setEdgeGlowColor(@NonNull EdgeEffectCompat edgeEffect, @ColorInt int color) throws Exception {
    Field field = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
    field.setAccessible(true);
    EdgeEffect effect = (EdgeEffect) field.get(edgeEffect);
    if (effect != null)
        effect.setColor(color);
}
 
开发者ID:cseshaiban,项目名称:app-theme-engine-master,代码行数:9,代码来源:EdgeGlowUtil.java

示例8: changeEdgeEffect

import android.widget.EdgeEffect; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static void changeEdgeEffect(Context cxt, View list, int glowColor, int lineColor) {
    if (Helper.isAtLeastAPI(Build.VERSION_CODES.LOLLIPOP)) {
        EdgeEffect edgeEffectTop = new EdgeEffect(cxt);
        edgeEffectTop.setColor(glowColor);
        EdgeEffect edgeEffectBottom = new EdgeEffect(cxt);
        edgeEffectBottom.setColor(glowColor);

        try {
            Field f1 = AbsListView.class.getDeclaredField("mEdgeGlowTop");
            f1.setAccessible(true);
            f1.set(list, edgeEffectTop);

            Field f2 = AbsListView.class.getDeclaredField("mEdgeGlowBottom");
            f2.setAccessible(true);
            f2.set(list, edgeEffectBottom);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        // Android < 5.0 - OverScroll Glow
        int glowDrawableId = cxt.getResources().getIdentifier("overscroll_glow", "drawable",
                "android");
        Drawable androidGlow = ContextCompat.getDrawable(cxt, glowDrawableId);
        androidGlow.setColorFilter(ContextCompat.getColor(cxt, glowColor),
                PorterDuff.Mode.SRC_ATOP);
        // Android < 5.0 - OverScroll Edge Line
        final int edgeDrawableId = cxt.getResources().getIdentifier("overscroll_edge",
                "drawable", "android");
        final Drawable overScrollEdge = ContextCompat.getDrawable(cxt, edgeDrawableId);
        overScrollEdge.setColorFilter(ContextCompat.getColor(cxt, lineColor),
                PorterDuff.Mode.SRC_ATOP);
    }
}
 
开发者ID:avluis,项目名称:Hentoid,代码行数:35,代码来源:Helper.java

示例9: setScrollViewEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:22,代码来源:AndroidUtilities.java

示例10: applyEdgeEffectColor

import android.widget.EdgeEffect; //导入方法依赖的package包/类
void applyEdgeEffectColor(EdgeEffectCompat edgeEffectCompat) {
    if (Build.VERSION.SDK_INT >= 21 && glowColor != 0) {
        try {
            Field field = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
            field.setAccessible(true);
            EdgeEffect edgeEffect = (EdgeEffect) field.get(edgeEffectCompat);
            if (edgeEffect != null) {
                edgeEffect.setColor(glowColor);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:15,代码来源:RecyclerView.java


注:本文中的android.widget.EdgeEffect.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。