AndroidUI库(1):液态效果ViewPager——com.github.Chrisvin:LiquidSwipe

引入依赖

implementation ('com.github.Chrisvin:LiquidSwipe:1.3')

SwipeActivity.java

 LiquidSwipeViewPager pager = (LiquidSwipeViewPager) findViewById(R.id.pager);
 final List<Fragment> fragments = new ArrayList<>();
 fragments.add(new Fragment(R.layout.f1));
 fragments.add(new Fragment(R.layout.f2));
 fragments.add(new Fragment(R.layout.f3));
 pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager(),BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
     @NonNull
     @Override
     public Fragment getItem(int position) {
         return fragments.get(position);
     }

     @Override
     public int getCount() {
         return fragments.size();
     }
 });

activity_swipe.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.jem.liquidswipe.LiquidSwipeViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

f1.xml

<?xml version="1.0" encoding="utf-8"?>
<com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:background="#2196F3"
    android:layout_height="match_parent">

</com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout>

f2.xml

<?xml version="1.0" encoding="utf-8"?>
<com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:background="#FB0303"
    android:layout_height="match_parent">

</com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout>

f3.xml

<?xml version="1.0" encoding="utf-8"?>
<com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:background="#00BCD4"
    android:layout_height="match_parent">

</com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout>

GitHub依赖库地址:https://github.com/568/LiquidSwipe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值