分析:案例当我们在屏幕中拖动一个方块运动时候,想让另外一个方块与其保持相同的位置关系的时候

以前我们的方式是 监听蓝色方块的移动然后将位置赋值给红色的方块,而现在不用,我们只需要给红色方块进行位置赋值就可以了

CoordinatorLayout的最简单使用

  <android.support.design.widget.FloatingActionButton
            android:src="@drawable/baseline_add_to_queue_black_18dp"
            app:layout_anchor="@id/bar_layout"
            app:layout_anchorGravity="bottom|end"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"/>

 

在CoordinatorLayout的包裹中控件会拥有 anchor属性和anchorGravity属性 设置这些属性可以让控件在另外的空间四周保持特定位置的连接  具体如代码所示

参考:https://www.jianshu.com/p/ed569a44225a

 

 

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-08-27
  • 2022-01-20
  • 2022-02-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2021-06-13
  • 2021-08-08
相关资源
相似解决方案