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


Java EdgeEffect类代码示例

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


EdgeEffect类属于android.widget包,在下文中一共展示了EdgeEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: HorizontalListView

import android.widget.EdgeEffect; //导入依赖的package包/类
public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffect(context);
    mEdgeGlowRight = new EdgeEffect(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling
    // tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
    ViewConfiguration vc = ViewConfiguration.get(context);
    mSlop = vc.getScaledTouchSlop();

}
 
开发者ID:EatHeat,项目名称:OmniSnitch,代码行数:20,代码来源:HorizontalListView.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) {
            FileLog.e("tmessages", e);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:22,代码来源:AndroidUtilities.java

示例4: 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

示例5: FmScroller

import android.widget.EdgeEffect; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param context The context
 * @param attrs The attrs
 * @param defStyleAttr The default attr
 */
public FmScroller(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    setFocusable(false);

    // Drawing must be enabled in order to support EdgeEffect
    setWillNotDraw(/* willNotDraw = */false);

    mEdgeGlowBottom = new EdgeEffect(context);
    mScroller = new Scroller(context, INTERPOLATOR);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final TypedArray attributeArray = context.obtainStyledAttributes(new int[] {
        android.R.attr.actionBarSize
    });
    mActionBarSize = attributeArray.getDimensionPixelSize(0, 0);
    attributeArray.recycle();
}
 
开发者ID:KobeMing,项目名称:FMRadio,代码行数:29,代码来源:FmScroller.java

示例6: 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

示例7: 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

示例8: PhotoViewPager

import android.widget.EdgeEffect; //导入依赖的package包/类
public PhotoViewPager(Context context, Adapter adapter) {
	super(context);
	setWillNotDraw(false);
	float density = ResourceUtils.obtainDensity(context);
	flingDistance = (int) (24 * density);
	ViewConfiguration configuration = ViewConfiguration.get(context);
	minimumVelocity = (int) (MIN_FLING_VELOCITY * density);
	maximumVelocity = configuration.getScaledMaximumFlingVelocity();
	touchSlop = configuration.getScaledTouchSlop();
	scroller = new OverScroller(context);
	edgeEffect = new EdgeEffect(context);
	this.adapter = adapter;
	for (int i = 0; i < 3; i++) {
		View view = adapter.onCreateView(this);
		super.addView(view, -1, generateDefaultLayoutParams());
		photoViews.add(adapter.getPhotoView(view));
	}
}
 
开发者ID:Mishiranu,项目名称:Dashchan,代码行数:19,代码来源:PhotoViewPager.java

示例9: setEdgeEffectsEnabled

import android.widget.EdgeEffect; //导入依赖的package包/类
/**
 * Controls whether the edge glows are enabled or not
 */
public void setEdgeEffectsEnabled(boolean val) {
	mEdgeEffectsEnabled = val;
	if (val) {
		Context context = getContext();
		setWillNotDraw(false);
		mLeftEdge = new EdgeEffect(context);
		mRightEdge = new EdgeEffect(context);
		mTopEdge = new EdgeEffect(context);
		mBottomEdge = new EdgeEffect(context);
	} else {
		setWillNotDraw(true);
		mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FreeFlowContainer.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("tmessages", e);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:15,代码来源:RecyclerView.java

示例11: setEdgeGlowColor

import android.widget.EdgeEffect; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void setEdgeGlowColor(Object edgeEffect, @ColorInt int color) {
    if (edgeEffect instanceof EdgeEffectCompat) {
        // EdgeEffectCompat
        try {
            edgeEffect = EDGE_EFFECT_COMPAT_FIELD_EDGE_EFFECT.get(edgeEffect);
        } catch (IllegalAccessException e) {
            if (BuildConfig.DEBUG) e.printStackTrace();
            return;
        }
    }

    if (edgeEffect == null) return;

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // EdgeGlow below Android 4 then old EdgeEffect
        try {
            final Drawable mEdge = (Drawable) EDGE_GLOW_FIELD_EDGE.get(edgeEffect);
            final Drawable mGlow = (Drawable) EDGE_GLOW_FIELD_GLOW.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 ex) {
            if (BuildConfig.DEBUG) ex.printStackTrace();
        }
    } else {
        // EdgeEffect
        ((EdgeEffect) edgeEffect).setColor(color);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:32,代码来源:Glow.java

示例12: setEffectColor

import android.widget.EdgeEffect; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void setEffectColor(Object edgeEffect, @ColorInt int color) {
    invalidateEdgeEffectFields();
    if (edgeEffect instanceof EdgeEffectCompat) {
        // EdgeEffectCompat
        try {
            EDGE_EFFECT_COMPAT_FIELD_EDGE_EFFECT.setAccessible(true);
            edgeEffect = EDGE_EFFECT_COMPAT_FIELD_EDGE_EFFECT.get(edgeEffect);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return;
        }
    }
    if (edgeEffect == null)
        return;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // EdgeGlow
        try {
            EDGE_GLOW_FIELD_EDGE.setAccessible(true);
            final Drawable mEdge = (Drawable) EDGE_GLOW_FIELD_EDGE.get(edgeEffect);
            EDGE_GLOW_FIELD_GLOW.setAccessible(true);
            final Drawable mGlow = (Drawable) EDGE_GLOW_FIELD_GLOW.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 ex) {
            ex.printStackTrace();
        }
    } else {
        // EdgeEffect
        ((EdgeEffect) edgeEffect).setColor(color);
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:35,代码来源:EdgeGlowUtil.java

示例13: setupEdgeEffect

import android.widget.EdgeEffect; //导入依赖的package包/类
protected void setupEdgeEffect(Context context) {

        // Sets up edge effects
        mEdgeEffectLeft = new EdgeEffect(context);
        mEdgeEffectTop = new EdgeEffect(context);
        mEdgeEffectRight = new EdgeEffect(context);
        mEdgeEffectBottom = new EdgeEffect(context);
    }
 
开发者ID:donglua,项目名称:JZAndroidChart,代码行数:9,代码来源:Chart.java

示例14: init

import android.widget.EdgeEffect; //导入依赖的package包/类
private void init() {
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mScroller = new Scroller(getContext(), new LinearInterpolator());
    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdgeEffect = new EdgeEffect(getContext());
    mRightEdgeEffect = new EdgeEffect(getContext());
    mShadePaint.setColor(Color.BLACK);
    mShinePaint.setColor(Color.WHITE);
}
 
开发者ID:Swati4star,项目名称:Travel-Mate,代码行数:12,代码来源:FlipViewPager.java

示例15: 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


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