android-pulse-indicator

android-pulse-indicator

简介:An Android View system for indicating Views using fading pulses

Download

An Android View system for indicating Views using fading pulses

pulse-indicator Sample

Installation

    repositories {
        jcenter()
    }

    dependencies {
        compile('com.jackpocket:pulse-indicator:1.0.4')
    }

Usage

Layout Approach

Make the root of your Activity's layout one of the base PulseLayouts included in this library: thePulsingLinearLayout or the PulsingRelativeLayout. e.g.

<com.jackpocket.pulse.layouts.PulsingLinearLayout 
    ...
    >

Then find it in your Activity and simply call PulseLayout.attachTo(Activity, View). Done. e.g.

((PulseLayout) findViewById(R.id.my_pulsing_layout))
    .attachTo(this, findViewById(R.id.some_view_I_want_to_indicate);
PulseView Approach

Just add a PulseView to your layout (make sure you're using a ViewGroup that allows overlapping children (e.g. RelativeLayout)).

<RelativeLayout>
    <com.jackpocket.pulse.layouts.PulseView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ... />
</RelativeLayout>

You could then use it the same way you would going the Layout Approach mentioned above.

Custom Approach

If you want to add pulsing to your own custom layouts, just checkout one of the supplied layout class files for detailed information on how to implemented the PulsingController manually.

Changing the values at runtime can also be configured by working with the PulseController:

((PulseLayout) findViewById(R.id.my_pulsing_layout))
    .attachTo(this, findViewById(R.id.some_view_I_want_to_indicate)
        .setCirclePathOverride(false) // Set it to use the rectangular boundaries instead of circle pulsing
        .setPulsingColor(0xFF22FF22) // Set the pulse starting color
        .setPulsingStrokeWidth(10) // Override the dynamic stroke width with a custom one
        .setDurationMs(1500) // Set the overall duration of the pulsing (will continue until no pulses exist)
        .setPulseLifespanMs(900) // The length of time a pulse is visible
        .setRespawnRateMs(300) // The rate at which a new pulse should be added
        .setAlphaInterpolator(new AccelerateInterpolator()) // Set the Interpolator for the alpha animation
        .setScaleInterpolator(new LinearInterpolator()) // Set the Interpolator for the scaling animation
        .setFinishedListener(view -> doSomethingOnFinished()); // Set a callback to be triggered when the pulsing finished for a View. Calling attach() before it completes will prevent it from being triggered

Configs

The default configs for pulsing color, duration, individual lifespan, respawn rates can be overwritten via the following, respectively:

R.color.pulse__color
R.integer.pulse__duration_default
R.integer.pulse__lifespan_default
R.integer.pulse__respawn_rate_default
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值