android一个可以让任意view具有滑动效果的库

描述:

android一个可以让任意view具有滑动效果的库

应用截图:

任意view具有滑动效果的库

源码解析:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add the dependency

dependencies {
    compile 'com.github.mancj:SlideUp-Android:1.0-beta'
}

Step 1:

create any type of layout

<LinearLayout
  android:id="@+id/slideView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

Step 2:

Find that view in your activity/fragment

View slideView = findViewById(R.id.slideView);

Step 3:

Create a SlideUp object and pass in your view

SlideUp slideUp = new SlideUp(slideView);
slideView = findViewById(R.id.slideView);
dim = findViewById(R.id.dim);
fab = (FloatingActionButton) findViewById(R.id.fab);

slideUp = new SlideUp(slideView);
slideUp.hideImmediately();

fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        slideUp.animateIn();
        fab.hide();
    }
});

slideUp.setSlideListener(new SlideUp.SlideListener() {
    @Override
    public void onSlide(float percent) {
        dim.setAlpha(1 - (percent / 100));
    }

    @Override
    public void onVisibilityChanged(int visibility) {
        if (visibility == View.GONE)
        {
            fab.show();
        }
    }
});

源码下载:https://github.com/mancj/SlideUp-Android

 

未经允许不得转载:安度博客 » android一个可以让任意view具有滑动效果的库

赞 (0)
分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址