Android让视图移动/缩放/透明度更改与其父滚动。

时间:2017-08-15 08:19 来源:互联网 作者:源码搜藏收藏

  • 源码类别:视图效果View Effects
  • 源码大小:未知
  • 编码格式:gbk,utf8,不限
  • 运行环境:Android studio
  • 广告推荐

SelfAdjointView是一个Android库,允许开发人员轻松地让视图随着可以滚动的父代更改。动画包含视差,alpha,scale的一个或多个。

适用于

  • 滚动型/ Horizo​​ntalScrollView
  • 的ListView / GridView控件
  • RecyclerView
  • ViewPager
  • 可以滚动的其他

影响


 .............


..............

样品

点击我

如何使用它?

建立

dependencies {
  // jCenter
  compile 'com.cysion:adjointlib:1.0.0'
}

视差

现在效果只能用于图像,而图像可以放置在任何视图组中,只要它是AdjointImageView,它由AdjointContainer包装。请注意,在这种情况下,AdjointContainer应该只有一个孩子,图像的高度/宽度应该大于容器(垂直移动)。

步骤1

布局中的代码

...<sth like scrollview>...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#66ffffff"
              android:orientation="horizontal"
              android:padding="10dp">
    <com.cysion.adjointlib.view.AdjointContainer
        android:id="@+id/container"
        android:layout_width="180dp"
        android:layout_height="100dp"
        android:layout_gravity="center_horizontal"
        android:layout_margin="10dp"
        >
        <com.cysion.adjointlib.view.AdjointImageView
            android:id="@+id/img_holder_img"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:background="#99ff0000"
            android:padding="3dp"
            />
    </com.cysion.adjointlib.view.AdjointContainer>
    ...other view...
</LinearLayout>
...</sth like scrollview>...

第2步

在Rect中设置滚动视图的位置,并为AdjointContainer提供定位器。

public  class  SecondActivity  扩展 AppCompatActivity  implements  Locator ...
mContainer1 =(AdjointContainer)findViewById(R .id.adcontainer1);
.. {
		mScrollView。postnew  Runnable(){
             @Override 
       		public  void run(){
		 	mScrollView getGlobalVisibleRect(MR);
 			mContainer1 setlocator命令(SecondActivity );
		}
});
.. 	}
	 @Override 
    public  Rect getLocation(){
         return mR;
    }

步骤3

创建一个AdjointStyle对象,并将其添加到容器中。

 AdjointStyle style =  new  VerticalMoveStyle()minScale(0.9f);
 mContainer1 addStyle(风格);

现在当父滚动时,图像也会滚动。

阿尔法/缩放

显示这些效果的视图应该包装在AdjointContainer中。

步骤1

布局中的代码

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroller"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <com.cysion.adjointlib.view.AdjointContainer
            android:id="@+id/adcontainer1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp">

            <com.cysion.adjointlib.view.AdjointImageView
                android:id="@+id/img_ad1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:src="@mipmap/p1c"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_alignParentBottom="true"
                android:layout_below="@+id/img_ad1"
                android:layout_centerHorizontal="true"
                android:text="Hello world"
                android:textColor="@color/colorPrimary"
                android:textSize="24sp"/>
        </com.cysion.adjointlib.view.AdjointContainer>
		....../other view.....
		....../other view.....
		....../other view.....
		....../other view.....
    </LinearLayout>

</ScrollView>

第2步

就像Parallex-step2中的step2一样。

步骤3

创建一个或多个AdjointStyle对象,并将其添加到容器中。

AdjointStyle style =  new  VerticalMoveStyle()minScale(0.9f);
AdjointStyle style2 =  new  VerticalAlphaStyle();
.. 
 mContainer1 addStyle(风格);
 mContainer1 addStyle(蓝紫魅力);
..

现在当父滚动时,图像将改变其alpha或scale。

本站资源仅限于学习研究,严禁从事商业或者非法活动! 源码搜藏网所有源码来自互联网转载与用户上传分享,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
上一篇:没有了

视图效果View Effects下载排行

最新文章